Class: Cmdlib::Command
- Inherits:
-
Object
- Object
- Cmdlib::Command
- Defined in:
- lib/cmdlib/command.rb
Overview
Class for create command object.
Instance Attribute Summary collapse
-
#argnum ⇒ Object
Mandatory argument numbers for command.
-
#brief ⇒ Object
Contain object with describe text.
-
#details ⇒ Object
Contain object with describe text.
-
#example ⇒ Object
Contain object with describe text.
-
#name ⇒ Object
Contain object with describe text.
-
#options ⇒ Object
List with options for command and subcommand.
-
#subcmd ⇒ Object
List with options for command and subcommand.
Instance Method Summary collapse
- #addcmd(cmd) ⇒ Object
- #addopt(opt) ⇒ Object
- #handler(global_options, args) ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
14 15 16 17 18 19 20 21 22 |
# File 'lib/cmdlib/command.rb', line 14 def initialize @name = '' @brief = '' @details = [] @example = [] @options = {} @subcmd = [] @argnum = 0 end |
Instance Attribute Details
#argnum ⇒ Object
Mandatory argument numbers for command.
12 13 14 |
# File 'lib/cmdlib/command.rb', line 12 def argnum @argnum end |
#brief ⇒ Object
Contain object with describe text.
6 7 8 |
# File 'lib/cmdlib/command.rb', line 6 def brief @brief end |
#details ⇒ Object
Contain object with describe text.
6 7 8 |
# File 'lib/cmdlib/command.rb', line 6 def details @details end |
#example ⇒ Object
Contain object with describe text.
6 7 8 |
# File 'lib/cmdlib/command.rb', line 6 def example @example end |
#name ⇒ Object
Contain object with describe text.
6 7 8 |
# File 'lib/cmdlib/command.rb', line 6 def name @name end |
#options ⇒ Object
List with options for command and subcommand.
9 10 11 |
# File 'lib/cmdlib/command.rb', line 9 def @options end |
#subcmd ⇒ Object
List with options for command and subcommand.
9 10 11 |
# File 'lib/cmdlib/command.rb', line 9 def subcmd @subcmd end |
Instance Method Details
#addcmd(cmd) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cmdlib/command.rb', line 38 def addcmd ( cmd ) raise TypeError, 'Incorrectly types for command object.' unless cmd.is_a? Cmdlib::Command @subcmd << cmd end |
#addopt(opt) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/cmdlib/command.rb', line 31 def addopt ( opt ) raise TypeError, 'Incorrectly types for option object.' unless opt.instance_of? Cmdlib::Option @options[opt.longname.to_sym] = opt end |
#handler(global_options, args) ⇒ Object
27 28 29 |
# File 'lib/cmdlib/command.rb', line 27 def handler( , args ) puts "error: handler do not set for this command." end |
#init ⇒ Object
24 25 |
# File 'lib/cmdlib/command.rb', line 24 def init end |