Class: R2do::Commands::HelpCommand
- Inherits:
-
R2do::Command
- Object
- R2do::Command
- R2do::Commands::HelpCommand
- Defined in:
- lib/r2do/commands/help_command.rb
Instance Attribute Summary
Attributes inherited from R2do::Command
#description, #extended, #short
Instance Method Summary collapse
-
#execute(args) ⇒ void
Initializes the applications and resets the datafile.
-
#initialize(cmd_list) ⇒ HelpCommand
constructor
A new instance of HelpCommand.
Methods inherited from R2do::Command
Constructor Details
#initialize(cmd_list) ⇒ HelpCommand
Returns a new instance of HelpCommand.
21 22 23 24 25 |
# File 'lib/r2do/commands/help_command.rb', line 21 def initialize(cmd_list) super('h', 'help', 'Shows the help for a given command') @cmd_list = cmd_list end |
Instance Method Details
#execute(args) ⇒ void
This method returns an undefined value.
Initializes the applications and resets the datafile
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/r2do/commands/help_command.rb', line 31 def execute(args) argument = args[1] cmd = @cmd_list.find { |c| c.short == argument or c.extended == argument } if cmd.nil? raise InvalidCommandError, "Invalid command. See 'r2do -h'" end UI.status(cmd.help()) end |