Class: HostedChef::ArgvParser
- Inherits:
-
Object
- Object
- HostedChef::ArgvParser
- Defined in:
- lib/hosted-chef/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ ArgvParser
constructor
A new instance of ArgvParser.
- #parse ⇒ Object
- #parser ⇒ Object
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
#options ⇒ Object (readonly)
Returns the value of attribute options.
82 83 84 |
# File 'lib/hosted-chef/cli.rb', line 82 def @options end |
Instance Method Details
#parse ⇒ Object
89 90 91 92 |
# File 'lib/hosted-chef/cli.rb', line 89 def parse parser.parse! end |
#parser ⇒ Object
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| .username = username end o.on("-p", "--password PASSWORD", "Your Hosted Chef password") do |passwd| .password = passwd end o.on('-o', "--organization ORGANIZATION", "Your Hosted Chef Organization") do |orgname| .orgname = orgname end o.on('-h', "--help") do puts o exit 1 end end end |