Class: CommandKit::Commands::Help
- Inherits:
-
CommandKit::Command
- Object
- CommandKit::Command
- CommandKit::Commands::Help
- Includes:
- ParentCommand
- Defined in:
- lib/command_kit/commands/help.rb
Overview
The default help command.
Constant Summary
Constants included from Printing
Instance Attribute Summary
Attributes included from ParentCommand
Attributes included from CommandKit::CommandName
Attributes included from Options
Attributes included from Options::Parser
Attributes included from Env
Instance Method Summary collapse
-
#run(command = nil) ⇒ Object
Prints the given commands
--help
output or lists registered commands.
Methods included from ParentCommand
Methods included from FileUtils
Methods included from ExceptionHandler
Methods included from Printing
#print_error, #print_exception
Methods included from Stdio
#abort, #gets, #initialize, #print, #printf, #putc, #puts, #readline, #readlines, #stderr, #stdin, #stdout
Methods included from Description
#description, #help, #help_description
Methods included from Description::ModuleMethods
Methods included from Help
Methods included from Help::ModuleMethods
Methods included from Examples
#examples, #help, #help_examples
Methods included from Examples::ModuleMethods
Methods included from CommandKit::CommandName
Methods included from CommandKit::CommandName::ModuleMethods
Methods included from Options
Methods included from Options::ModuleMethods
Methods included from Options::Parser
#help, #help_options, #initialize, #main, #on_ambiguous_argument, #on_ambiguous_option, #on_invalid_argument, #on_invalid_option, #on_missing_argument, #on_needless_argument, #on_parse_error, #parse_options
Methods included from Options::Parser::ModuleMethods
Methods included from Main
Methods included from Main::ModuleMethods
Methods included from Usage
Methods included from Usage::ModuleMethods
Methods included from Arguments
Methods included from Arguments::ModuleMethods
Methods included from Env
Instance Method Details
#run(command = nil) ⇒ Object
Prints the given commands --help
output or lists registered commands.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/command_kit/commands/help.rb', line 26 def run(command=nil) case command when nil parent_command.help else if (subcommand = parent_command.command(command)) unless subcommand.respond_to?(:help) raise(TypeError,"#{subcommand.inspect} must define a #help method") end subcommand.help else print_error "unknown command: #{command}" exit(1) end end end |