Class: EYCli::OptionsParser
- Inherits:
-
Object
- Object
- EYCli::OptionsParser
- Defined in:
- lib/ey_cli/options_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ OptionsParser
constructor
A new instance of OptionsParser.
- #options_parser ⇒ Object
- #parse(args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OptionsParser
Returns a new instance of OptionsParser.
11 12 13 |
# File 'lib/ey_cli/options_parser.rb', line 11 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/ey_cli/options_parser.rb', line 5 def @options end |
Class Method Details
.parse(args) ⇒ Object
7 8 9 |
# File 'lib/ey_cli/options_parser.rb', line 7 def self.parse(args) new.parse(args) end |
Instance Method Details
#options_parser ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ey_cli/options_parser.rb', line 23 def ::OptionParser.new do |opts| opts. = 'ey_cli options:' opts.separator ' ' opts.on('-v', '--version', 'display the current version') do puts "ey_cli #{EYCli::VERSION}" exit end opts.on('-a', '--account ACCOUNT_NAME') do |account| [:account] = account end opts.on('-p', '--app APP_NAME') do |app| [:app] = app end opts.on('-e', '--environment ENVIRONMENT_NAME') do |environment| [:environment] = environment end end end |
#parse(args) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ey_cli/options_parser.rb', line 15 def parse(args) .parse!(args) rescue OptionParser::InvalidOption => e p e, exit 1 end |