Class | Pry::ClassCommand |
In: |
lib/pry/command.rb
|
Parent: | Command |
A super-class ofr Commands with structure.
This class implements the bare-minimum functionality that a command should have, namely a —help switch, and then delegates actual processing to its subclasses.
Create subclasses using {Pry::CommandSet#create_command}, and override the `options(opt)` method to set up an instance of Slop, and the `process` method to actually run the command. If necessary, you can also override `setup` which will be called before `options`, for example to require any gems your command needs to run, or to set up state.
args | [RW] | |
opts | [RW] |
A function to setup Slop so it can parse the options your command expects.
NOTE: please don‘t do anything side-effecty in the main part of this method, as it may be called by Pry at any time for introspection reasons. If you need to set up default values, use `setup` instead.
@example
def options(opt) opt.banner "Gists methods or classes" opt.on(:c, :class, "gist a class") do @action = :class end end
The actual body of your command should go here.
The `opts` mehod can be called to get the options that Slop has passed, and `args` gives the remaining, unparsed arguments.
The return value of this method is discarded unless the command was created with `:keep_retval => true`, in which case it is returned to the repl.
@example
def process if opts.present?(:class) gist_class else gist_method end end