Class: Prepd::Cli::OptionsParser
- Inherits:
-
Object
- Object
- Prepd::Cli::OptionsParser
- Defined in:
- lib/prepd/cli/options_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ OptionsParser
constructor
A new instance of OptionsParser.
- #parse ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ OptionsParser
Returns a new instance of OptionsParser.
7 8 9 |
# File 'lib/prepd/cli/options_parser.rb', line 7 def initialize( = nil) self. = || {} end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/prepd/cli/options_parser.rb', line 5 def @options end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/prepd/cli/options_parser.rb', line 11 def parse optparse = OptionParser.new do |opts| opts.on('-c', '--client [OPT]', 'Client') do |value| ['CLIENT'] = value end opts.on( '-d', '--data_dir [OPT]', 'Data directory' ) do |value| ['DATA_DIR'] = value end opts.on( '-p', '--project [OPT]', 'Project' ) do |value| ['PROJECT'] = value end opts.on('-h', '--help', 'Display this screen') do puts opts exit end opts.on('-n', '--no-op', 'Show what would happen but do not execute') do .no_op = true end opts.on('-v', '--verbose', 'Display additional information') do .verbose = true end end optparse.parse! end |