Manage the processing of command line options
@return [Array<String>] The input array of strings to process
as CLI options.
@return [Array] The Procs that process the parsed options.
@return [Proc] The Proc defining the valid command line options.
Add another set of CLI options (a Slop block)
# File lib/pry/cli.rb, line 22 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
# File lib/pry/cli.rb, line 37 def add_plugin_options Pry.plugins.values.each do |plugin| plugin.load_cli_options end self end
# File lib/pry/cli.rb, line 59 def parse_options(args=ARGV.dup) unless options raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." end self.input_args = args opts = Slop.parse!(args, :help => true, :multiple_switches => false, &options) # Option processors are optional. if option_processors option_processors.each { |processor| processor.call(opts) } end self end
Add a block responsible for processing parsed options.
# File lib/pry/cli.rb, line 46 def process_options(&block) self.option_processors ||= [] option_processors << block self end
Clear `options` and `::option_processors`
# File lib/pry/cli.rb, line 54 def reset self.options = nil self.option_processors = nil end