Class: Inch::CLI::Command::Base Abstract
- Inherits:
-
Object
- Object
- Inch::CLI::Command::Base
- Includes:
- TraceHelper
- Defined in:
- lib/inch/cli/command/base.rb
Overview
This class is abstract.
Note:
This was adapted from YARD.
Abstract base class for CLI utilities. Provides some helper methods for the option parser
Direct Known Subclasses
Instance Attribute Summary collapse
-
#source_parser ⇒ Object
readonly
Returns the value of attribute source_parser.
Class Method Summary collapse
-
.run(*args) ⇒ Object
Helper method to run the utility on an instance.
Instance Method Summary collapse
-
#description ⇒ String
Returns a description of the command.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#name ⇒ String
Returns the name of the command by which it is referenced in the command list.
-
#usage ⇒ String
Returns a description of the command’s usage pattern.
Methods included from TraceHelper
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
23 24 25 26 27 |
# File 'lib/inch/cli/command/base.rb', line 23 def initialize = "Command::Options::#{self.class.to_s.split('::').last}" @options = eval().new @options.usage = usage end |
Instance Attribute Details
#source_parser ⇒ Object (readonly)
Returns the value of attribute source_parser.
13 14 15 |
# File 'lib/inch/cli/command/base.rb', line 13 def source_parser @source_parser end |
Class Method Details
.run(*args) ⇒ Object
Helper method to run the utility on an instance.
17 18 19 20 21 |
# File 'lib/inch/cli/command/base.rb', line 17 def self.run(*args) command = new command.run(*args) command end |
Instance Method Details
#description ⇒ String
Returns a description of the command
31 32 33 |
# File 'lib/inch/cli/command/base.rb', line 31 def description "" end |
#name ⇒ String
Returns the name of the command by which it is referenced in the command list.
38 39 40 41 42 |
# File 'lib/inch/cli/command/base.rb', line 38 def name CommandParser.commands.each do |name, klass| return name if klass == self.class end end |
#usage ⇒ String
Returns a description of the command’s usage pattern
46 47 48 |
# File 'lib/inch/cli/command/base.rb', line 46 def usage "Usage: inch #{name} [options]" end |