Class: Bosh::Cli::CommandDefinition
- Defined in:
- lib/cli/command_definition.rb
Instance Attribute Summary collapse
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#power_options ⇒ Object
readonly
Returns the value of attribute power_options.
Instance Method Summary collapse
- #description(str = nil) ⇒ Object (also: #desc)
-
#initialize ⇒ CommandDefinition
constructor
A new instance of CommandDefinition.
- #option(name, value = "") ⇒ Object
- #power_option(name, value = "") ⇒ Object
- #route(*args, &block) ⇒ Object
- #usage(str = nil) ⇒ Object
Constructor Details
#initialize ⇒ CommandDefinition
Returns a new instance of CommandDefinition.
9 10 11 12 13 14 |
# File 'lib/cli/command_definition.rb', line 9 def initialize @options = [] @power_options = [] @hints = [] @keywords = [] end |
Instance Attribute Details
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
7 8 9 |
# File 'lib/cli/command_definition.rb', line 7 def keywords @keywords end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/cli/command_definition.rb', line 5 def @options end |
#power_options ⇒ Object (readonly)
Returns the value of attribute power_options.
6 7 8 |
# File 'lib/cli/command_definition.rb', line 6 def @power_options end |
Instance Method Details
#description(str = nil) ⇒ Object Also known as: desc
27 28 29 |
# File 'lib/cli/command_definition.rb', line 27 def description(str = nil) str ? (@description = str.to_s.strip) : @description end |
#option(name, value = "") ⇒ Object
33 34 35 |
# File 'lib/cli/command_definition.rb', line 33 def option(name, value = "") @options << [name, value] end |
#power_option(name, value = "") ⇒ Object
37 38 39 |
# File 'lib/cli/command_definition.rb', line 37 def power_option(name, value = "") @power_options << [name, value] end |
#route(*args, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/cli/command_definition.rb', line 41 def route(*args, &block) if args.size > 0 @route = args elsif block_given? @route = block else @route end end |
#usage(str = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cli/command_definition.rb', line 16 def usage(str = nil) if str @usage = str.strip @keywords = str.split(/\s+/).select do |word| word.match(/^[a-z]/i) end else @usage end end |