Class: BabelYoda::Options
- Inherits:
-
Object
- Object
- BabelYoda::Options
- Defined in:
- lib/babelyoda/options.rb
Class Method Summary collapse
-
.parse ⇒ Object
Return a structure describing the options.
Class Method Details
.parse ⇒ Object
Return a structure describing the options.
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 |
# File 'lib/babelyoda/options.rb', line 12 def self.parse # The options specified on the command line will be collected in *options*. # We set default values here. = { 'rules' => 'rules.babelyoda' } optparser = OptionParser.new do |opts| opts. = "Usage: babelyoda [options]" opts.separator "" opts.separator "Common options:" # Optional argument; multi-line description. opts.on("-r", "--rules <RULES-FILE>", "Use the specified rules file.", "Default is 'babelyoda.rules'.") do |rules| ['rules'] = rules end # No argument, shows at tail. This will print an options summary. opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end optparser.parse! end |