Class | Bat::Optparser |
In: |
lib/bat.rb
|
Parent: | Object |
Constructs very basic option parser object. You still will have to spend a fair amount of time on creating the actual options. If I knew how to pass the desired variable name as exactly that, a variable name, to be used for enhancing the OpenStruct one could reduce adding an item to one method call with 4 arguments. So imagine the following being actually 3 lines if I was a better haxx0r (or ultimately I had intarwebs access right now ;-)
I imagine something like Optparser::add_bool() to add new options in a comfortable way…
Optparser.new() $options.build = true $opts.on("-b", "--no-build", "Don't testbuild") do |nobuild| $options.build = nobuild end $opts.parse!(ARGV)
For more information please consult the OptionParser documentatin. The basic method structure is short option | long option | description | do something. You can also describe mandatory arguments by writing them in upper case, or optional arguments using [ARG].
$opts.on("-s", "--build-slave SLAVE", "SLAVE makes it a mandatory argument for --build-slave")