class Fuelcell::Action::Command
Represents the action you want to perform. It also holds a list of option definitions used by the parser, along with meta data used by the help system and callable which is any object that implements call, this is your action.
Attributes
Public Class Methods
Every command initializes with only its name set expecting the dsl to finish assigning the rest of its properties
@param name [String]
# File lib/fuelcell/action/command.rb, line 21 def initialize(name) @name = name.to_s @usage = nil @desc = nil @opts = OptsManager.new @args = ArgsManager.new end
Public Instance Methods
Allows all the global option definitions from this command hierarchy to be add to the command given
@param cmd [Fuelcell::Action::Command] @return [Fuelcell::Action::Command]
# File lib/fuelcell/action/command.rb, line 66 def add_global_options(cmd) return cmd if self === cmd global_options(cmd).each do |_key, opt_definition| cmd.opt opt_definition end cmd end
Allows a command to add subcommands to itself
@param key [String] @yield instance_eval into Fuelcell::Command @return Fuelcell::Command
# File lib/fuelcell/action/command.rb, line 55 def command(key, &block) cmd = Command.new(key) cmd.instance_eval(&block) add cmd end
Both getting and setter for description
@param text [String] @return [String]
# File lib/fuelcell/action/command.rb, line 45 def desc(text = nil) return @desc if text.nil? @desc = text end
This will assign both usage text and description, but when called with no args it will get the usage
@param text [String] @param desc_text [String] @return [String]
# File lib/fuelcell/action/command.rb, line 35 def usage(text = nil, desc_text = nil) return @usage if text.nil? desc(desc_text) unless desc_text.nil? @usage = text end