Class: HostedChef::ArgvParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hosted-chef/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ArgvParser

Returns a new instance of ArgvParser.



84
85
86
87
# File 'lib/hosted-chef/cli.rb', line 84

def initialize(argv)
  @options = Options.new
  @argv = argv
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



82
83
84
# File 'lib/hosted-chef/cli.rb', line 82

def options
  @options
end

Instance Method Details

#parseObject



89
90
91
92
# File 'lib/hosted-chef/cli.rb', line 89

def parse
  parser.parse!
  options
end

#parserObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/hosted-chef/cli.rb', line 94

def parser
  OptionParser.new do |o|
    o.on("-u", "--user USERNAME", "Your Hosted Chef username") do |username|
      options.username = username
    end

    o.on("-p", "--password PASSWORD", "Your Hosted Chef password") do |passwd|
      options.password = passwd
    end

    o.on('-o', "--organization ORGANIZATION", "Your Hosted Chef Organization") do |orgname|
      options.orgname = orgname
    end

    o.on('-h', "--help") do
      puts o
      exit 1
    end
  end
end