Class: Kut::HelpCommand
- Inherits:
-
Object
- Object
- Kut::HelpCommand
- Defined in:
- lib/kut/commands/help-cmd.rb
Instance Attribute Summary collapse
-
#help_banner ⇒ Object
readonly
Returns the value of attribute help_banner.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #help(args) ⇒ Object
-
#initialize ⇒ HelpCommand
constructor
A new instance of HelpCommand.
- #run(args) ⇒ Object
- #show_cmd_help(cmd_name, args) ⇒ Object
Constructor Details
#initialize ⇒ HelpCommand
Returns a new instance of HelpCommand.
8 9 10 11 |
# File 'lib/kut/commands/help-cmd.rb', line 8 def initialize @name = 'help' @help_banner = 'Help for information on a specific command.' end |
Instance Attribute Details
#help_banner ⇒ Object (readonly)
Returns the value of attribute help_banner.
6 7 8 |
# File 'lib/kut/commands/help-cmd.rb', line 6 def @help_banner end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/kut/commands/help-cmd.rb', line 5 def name @name end |
Instance Method Details
#help(args) ⇒ Object
13 14 15 |
# File 'lib/kut/commands/help-cmd.rb', line 13 def help(args) @help_banner end |
#run(args) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/kut/commands/help-cmd.rb', line 24 def run(args) Kut.application.show_help() unless args Kut.application.show_help() if args.size() == 0 help_args = args.dup() help_args.delete_at(0) show_cmd_help(args[0], help_args) end |
#show_cmd_help(cmd_name, args) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/kut/commands/help-cmd.rb', line 17 def show_cmd_help(cmd_name, args) cmd = Kut.application.command_by_name(cmd_name) puts cmd.help(args) if cmd puts "Help for command #{cmd_name} not found." unless cmd exit end |