Class: Bosh::Cli::CommandDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/command_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandDefinition

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

#keywordsObject (readonly)

Returns the value of attribute keywords.



7
8
9
# File 'lib/cli/command_definition.rb', line 7

def keywords
  @keywords
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/cli/command_definition.rb', line 5

def options
  @options
end

#power_optionsObject (readonly)

Returns the value of attribute power_options.



6
7
8
# File 'lib/cli/command_definition.rb', line 6

def power_options
  @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