Class: Inch::CLI::CommandParser
- Inherits:
-
Object
- Object
- Inch::CLI::CommandParser
- Includes:
- TraceHelper
- Defined in:
- lib/inch/cli/command_parser.rb
Overview
This class parses a command name out of the inch CLI command and calls that command in the form:
$ inch command_name []
If no command_name is specified, the CommandParser.default_command will be used.
Class Attribute Summary collapse
-
.commands ⇒ Hash{Symbol => Command}
The mapping of command names to command classes to parse the user command.
-
.default_command ⇒ Symbol
The default command name to use when no options are specified or.
Class Method Summary collapse
-
.run(*args) ⇒ void
Convenience method to create a new CommandParser and call #run.
Instance Method Summary collapse
-
#initialize ⇒ CommandParser
constructor
A new instance of CommandParser.
-
#run(*args) ⇒ void
Runs the Command object matching the command name of the first argument.
Methods included from TraceHelper
Constructor Details
#initialize ⇒ CommandParser
Returns a new instance of CommandParser.
41 42 43 |
# File 'lib/inch/cli/command_parser.rb', line 41 def initialize #log.show_backtraces = false end |
Class Attribute Details
.commands ⇒ Hash{Symbol => Command}
Returns the mapping of command names to command classes to parse the user command.
17 18 19 |
# File 'lib/inch/cli/command_parser.rb', line 17 def commands @commands end |
.default_command ⇒ Symbol
Returns the default command name to use when no options are specified or.
21 22 23 |
# File 'lib/inch/cli/command_parser.rb', line 21 def default_command @default_command end |
Class Method Details
.run(*args) ⇒ void
This method returns an undefined value.
Convenience method to create a new CommandParser and call #run
37 38 39 |
# File 'lib/inch/cli/command_parser.rb', line 37 def self.run(*args) new.run(*args) end |
Instance Method Details
#run(*args) ⇒ void
This method returns an undefined value.
Runs the Inch::CLI::Command object matching the command name of the first argument.
48 49 50 51 52 53 54 |
# File 'lib/inch/cli/command_parser.rb', line 48 def run(*args) if ['--help', '-h'].include?(args.join) list_commands else run_command(*args) end end |