<commit_before>#!/usr/bin/env ruby

# console:  interactive wallaby environment
#
# Copyright (c) 2009--2010 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'irb'

module Wallaby
  def self.store
    @wallaby_store
  end

  def self.store=(ws)
    @wallaby_store = ws
  end
  
  def store
    ::Wallaby::store
  end
end

module Mrg
  module Grid
    module Config
      module Shell
        class Console
          def initialize(storeclient, name, op=:console)

            @op = op
            @store = storeclient
            @name = name

            @options = {}
            @oparser = OptionParser.new do |opts|
              
              opname = "console"
              
              opts.banner = "Usage:  wallaby #{opname}\ninteractive wallaby environment."
                
              opts.on("-h", "--help", "displays this message") do
                puts @oparser
                exit
              end
            end

          end
          
          def main(args)
            begin
              @oparser.parse!(args)
            rescue OptionParser::InvalidOption
              puts @oparser
              return
            rescue OptionParser::InvalidArgument => ia
              puts ia
              puts @oparser
              return
            end
            
            act
          end
          
          def act(kwargs=nil)
            ARGV.clear
            ::Wallaby::store = @store
            ::IRB.start
          end
          
        end

        Mrg::Grid::Config::Shell::COMMANDS['console'] = Console
        
      end
    end
  end
end
<commit_msg>It is now possible to use 'wallaby console' for shebang scripts.<commit_after>#!/usr/bin/env ruby

# console:  interactive wallaby environment
#
# Copyright (c) 2009--2010 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'irb'

module Wallaby
  def self.store
    @wallaby_store
  end

  def self.store=(ws)
    @wallaby_store = ws
  end
  
  def store
    ::Wallaby::store
  end
end

module Mrg
  module Grid
    module Config
      module Shell
        class Console
          def initialize(storeclient, name, op=:console)

            @op = op
            @store = storeclient
            @name = name

            @options = {}
            @oparser = OptionParser.new do |opts|
              
              opname = "console"
              
              opts.banner = "Usage:  wallaby #{opname} [SCRIPT...]\ninteractive wallaby environment."
              
              opts.on("-h", "--help", "displays this message") do
                puts @oparser
                exit
              end

              opts.on("-r", "--require-file FILE", "require FILE before doing anything else") do |file|
                @loadfiles << file
              end

            end

          end
          
          def main(args)
            begin
              @loadfiles = []
              @oparser.parse!(args)
              @evalfiles = args.dup
            rescue OptionParser::InvalidOption
              puts @oparser
              return
            rescue OptionParser::InvalidArgument => ia
              puts ia
              puts @oparser
              return
            end
            
            act
          end
          
          def act(kwargs=nil)
            ARGV.clear
            ::Wallaby::store = @store
            @loadfiles.each {|f| require f }
            if @evalfiles.size > 0
              begin
                @evalfiles.each {|f| load f }
                0
              rescue Exception=>e
                puts "script failed; #{e}"
                1
              end
            else
              ::IRB.start
            end
          end
          
        end

        Mrg::Grid::Config::Shell::COMMANDS['console'] = Console
        
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07714521452145215, 'fraction_numerical': 0.005569306930693069, 'mean_word_length': 1.4539473684210527, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6188730', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1244, 'n_words': 425}