<commit_before>
class Pry

  # Manage the processing of command line options
  class CLI

    NoOptionsError = Class.new(StandardError)

    class << self

      # @return [Proc] The Proc defining the valid command line options.
      attr_accessor :options

      # @return [Array] The Procs that process the parsed options.
      attr_accessor :option_processors

      # @return [Array<String>] The input array of strings to process
      #   as CLI options.
      attr_accessor :input_args

      # Add another set of CLI options (a Slop block)
      def add_options(&block)
        if options
          old_options = options
          self.options = proc do
            instance_exec(&old_options)
            instance_exec(&block)
          end
        else
          self.options = block
        end

        self
      end

      # Bring in options defined in plugins
      def add_plugin_options
        Pry.plugins.values.each do |plugin|
          plugin.load_cli_options
        end

        self
      end

      # Add a block responsible for processing parsed options.
      def process_options(&block)
        self.option_processors ||= []
        option_processors << block

        self
      end

      # Clear `options` and `option_processors`
      def reset
        self.options           = nil
        self.option_processors = nil
      end

      def parse_options(args=ARGV.dup)
        raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." if !options

        self.input_args = args

        opts = Slop.parse!(args, :help => true, :multiple_switches => false, &options)
        option_processors.each { |processor| processor.call(opts) } if option_processors # option processors are optional

        self
      end

    end

    reset
  end
end

# Bring in options defined by plugins
Pry::CLI.add_plugin_options

# The default Pry command line options (before plugin options are included)
Pry::CLI.add_options do
  banner %{Usage: pry [OPTIONS]
Start a Pry session.
See: `https://github.com/pry` for more information.
Copyright (c) 2011 <NAME> (banisterfiend)
--
}
  on :e, :exec, "A line of code to execute in context before the session starts", :argument => true

  on "no-pager", "Disable pager for long output" do
    Pry.config.pager = false
  end

  on "no-history", "Disable history loading" do
    Pry.config.history.should_load = false
  end

  on "no-color", "Disable syntax highlighting for session" do
    Pry.color = false
  end

  on :f, "Suppress loading of ~/.pryrc and ./.pryrc" do
    Pry.config.should_load_rc = false
    Pry.config.should_load_local_rc = false
  end

  on :s, "select-plugin", "Only load specified plugin (and no others).", :argument => true do |plugin_name|
    Pry.config.should_load_plugins = false
    Pry.plugins[plugin_name].activate!
  end

  on :d, "disable-plugin", "Disable a specific plugin.", :argument => true do |plugin_name|
    Pry.plugins[plugin_name].disable!
  end

  on "no-plugins", "Suppress loading of plugins." do
    Pry.config.should_load_plugins = false
  end

  on "installed-plugins", "List installed plugins." do
    puts "Installed Plugins:"
    puts "--"
    Pry.locate_plugins.each do |plugin|
      puts "#{plugin.name}".ljust(18) + plugin.spec.summary
    end
    exit
  end

  on "simple-prompt", "Enable simple prompt mode" do
    Pry.config.prompt = Pry::SIMPLE_PROMPT
  end

  on :r, :require, "`require` a Ruby script at startup", :argument => true do |file|
    Pry.config.requires << file
  end

  on :I, "Add a path to the $LOAD_PATH", :argument => true do |path|
    $LOAD_PATH << path
  end

  on :v, :version, "Display the Pry version" do
    puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
    exit
  end

  on(:c, :context,
     "Start the session in the specified context. Equivalent to `context.pry` in a session.",
     :argument => true,
     :default => "Pry.toplevel_binding"
     )
end.process_options do |opts|

  exit if opts.help?

  # invoked via cli
  Pry.cli = true

  # create the actual context
  context = Pry.binding_for(eval(opts[:context]))

  if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
    full_name = File.expand_path(Pry::CLI.input_args.first)
    Pry.load_file_through_repl(full_name)
    exit
  elsif opts[:exec]
    exec_string = opts[:exec] + "\n"
  else
    exec_string = ""
  end

  # Start the session (running any code passed with -e, if there is any)
  Pry.start(context, :input => StringIO.new(exec_string))
end
<commit_msg>added exec flag chaining<commit_after>
class Pry

  # Manage the processing of command line options
  class CLI

    NoOptionsError = Class.new(StandardError)

    class << self

      # @return [Proc] The Proc defining the valid command line options.
      attr_accessor :options

      # @return [Array] The Procs that process the parsed options.
      attr_accessor :option_processors

      # @return [Array<String>] The input array of strings to process
      #   as CLI options.
      attr_accessor :input_args

      # Add another set of CLI options (a Slop block)
      def add_options(&block)
        if options
          old_options = options
          self.options = proc do
            instance_exec(&old_options)
            instance_exec(&block)
          end
        else
          self.options = block
        end

        self
      end

      # Bring in options defined in plugins
      def add_plugin_options
        Pry.plugins.values.each do |plugin|
          plugin.load_cli_options
        end

        self
      end

      # Add a block responsible for processing parsed options.
      def process_options(&block)
        self.option_processors ||= []
        option_processors << block

        self
      end

      # Clear `options` and `option_processors`
      def reset
        self.options           = nil
        self.option_processors = nil
      end

      def parse_options(args=ARGV.dup)
        raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." if !options

        self.input_args = args

        opts = Slop.parse!(args, :help => true, :multiple_switches => false, &options)
        option_processors.each { |processor| processor.call(opts) } if option_processors # option processors are optional

        self
      end

    end

    reset
  end
end


# String that is built to be executed on start (created by -e and -exec switches)
exec_string = ""

# Bring in options defined by plugins
Pry::CLI.add_plugin_options

# The default Pry command line options (before plugin options are included)
Pry::CLI.add_options do
  banner %{Usage: pry [OPTIONS]
Start a Pry session.
See: `https://github.com/pry` for more information.
Copyright (c) 2011 <NAME> (banisterfiend)
--
}
  on :e, :exec, "A line of code to execute in context before the session starts", :argument => true do |input|
    exec_string << input + "\n"
  end

  on "no-pager", "Disable pager for long output" do
    Pry.config.pager = false
  end

  on "no-history", "Disable history loading" do
    Pry.config.history.should_load = false
  end

  on "no-color", "Disable syntax highlighting for session" do
    Pry.color = false
  end

  on :f, "Suppress loading of ~/.pryrc and ./.pryrc" do
    Pry.config.should_load_rc = false
    Pry.config.should_load_local_rc = false
  end

  on :s, "select-plugin", "Only load specified plugin (and no others).", :argument => true do |plugin_name|
    Pry.config.should_load_plugins = false
    Pry.plugins[plugin_name].activate!
  end

  on :d, "disable-plugin", "Disable a specific plugin.", :argument => true do |plugin_name|
    Pry.plugins[plugin_name].disable!
  end

  on "no-plugins", "Suppress loading of plugins." do
    Pry.config.should_load_plugins = false
  end

  on "installed-plugins", "List installed plugins." do
    puts "Installed Plugins:"
    puts "--"
    Pry.locate_plugins.each do |plugin|
      puts "#{plugin.name}".ljust(18) + plugin.spec.summary
    end
    exit
  end

  on "simple-prompt", "Enable simple prompt mode" do
    Pry.config.prompt = Pry::SIMPLE_PROMPT
  end

  on :r, :require, "`require` a Ruby script at startup", :argument => true do |file|
    Pry.config.requires << file
  end

  on :I, "Add a path to the $LOAD_PATH", :argument => true do |path|
    $LOAD_PATH << path
  end

  on :v, :version, "Display the Pry version" do
    puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
    exit
  end

  on(:c, :context,
     "Start the session in the specified context. Equivalent to `context.pry` in a session.",
     :argument => true,
     :default => "Pry.toplevel_binding"
     )
end.process_options do |opts|

  exit if opts.help?

  # invoked via cli
  Pry.cli = true

  # create the actual context
  context = Pry.binding_for(eval(opts[:context]))

  if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
    full_name = File.expand_path(Pry::CLI.input_args.first)
    Pry.load_file_through_repl(full_name)
    exit
  end

  # Start the session (running any code passed with -e, if there is any)
  Pry.start(context, :input => StringIO.new(exec_string))
end

{'fraction_non_alphanumeric': 0.09708315193730953, 'fraction_numerical': 0.00130605137135394, 'mean_word_length': 2.747553017944535, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '1918573', 'n_tokens_mistral': 2917, 'n_tokens_neox': 2810, 'n_words': 918}