Class: Pry::CLI
Overview
Manage the processing of command line options
Constant Summary
- NoOptionsError =
Class.new(StandardError)
Class Attribute Summary (collapse)
-
+ (Array) option_processors
The Procs that process the parsed options.
-
+ (Proc) options
The Proc defining the valid command line options.
Class Method Summary (collapse)
-
+ (Object) add_options(&block)
Add another set of CLI options (a Slop block).
-
+ (Object) add_plugin_options
Bring in options defined in plugins.
- + (Object) parse_options(args = ARGV.dup)
-
+ (Object) process_options(&block)
Add a block responsible for processing parsed options.
-
+ (Object) reset
Clear
optionsandoption_processors.
Class Attribute Details
+ (Array) option_processors
The Procs that process the parsed options.
15 16 17 |
# File 'lib/pry/cli.rb', line 15 def option_processors @option_processors end |
+ (Proc) options
The Proc defining the valid command line options.
12 13 14 |
# File 'lib/pry/cli.rb', line 12 def @options end |
Class Method Details
+ (Object) add_options(&block)
Add another set of CLI options (a Slop block)
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pry/cli.rb', line 18 def (&block) if = self. = proc do instance_exec(&) instance_exec(&block) end else self. = block end self end |
+ (Object) add_plugin_options
Bring in options defined in plugins
33 34 35 36 37 38 39 |
# File 'lib/pry/cli.rb', line 33 def Pry.plugins.values.each do |plugin| plugin. end self end |
+ (Object) parse_options(args = ARGV.dup)
55 56 57 58 59 60 61 62 |
# File 'lib/pry/cli.rb', line 55 def (args=ARGV.dup) raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options." if ! opts = Slop.parse(args, :help => true, :multiple_switches => false, &) option_processors.each { |processor| processor.call(opts) } if option_processors # option processors are optional self end |
+ (Object) process_options(&block)
Add a block responsible for processing parsed options.
42 43 44 45 46 47 |
# File 'lib/pry/cli.rb', line 42 def (&block) self.option_processors ||= [] option_processors << block self end |
+ (Object) reset
Clear options and option_processors
50 51 52 53 |
# File 'lib/pry/cli.rb', line 50 def reset self. = nil self.option_processors = nil end |