Author: Jim Freeze Copyright 2005 Jim Freeze
CommandLine::OptionParser is part of the CommandLine suite of tools and is used for command line parsing. The command line parser suite consists of classes CommandLine::Option, CommandLine::OptionData and CommandLine::Application.
The parser supports POSIX, Gnu and XTools style parsing options. It also provides flexibility to support non standard options. For example:
OptionParser.new Option.new(:posix, :names => “-f”)
OptionParser.new Option.new(:names => %w[–file -f])
OptionParser.new Option.new(:names => “-file”)
:names => %w(--file -file --files -files -f), :arg_arity => [1,-1], :arg_description => "file1 [file2, ...]"))
This last option prints:
OPTIONS --file,-file,--files,-files,-f file1 [file2, ...]
After poking around in a few corporations, it was evident that option parsing was not well understood. Therefore, many inhouse tools were built that did not conform to any of the POSIX, Gnu or XTools option styles. CommandLine::OptionParser was developed so that new applications could be written that conformed to accepted standards, but non-standard option configurations could be handled as well to support legacy interfaces.
More information and usage scenarios on OptionParser can be found at:
Download & Installation
Currently optionparser is only available as a rubygem.
$ gem install optionparser
All feedback is appreciated!
Installations not available yet
# not in RPA yet Via RPA
$ rpa install optionparser
# this either The do-it-yourself way
$ ruby setup.rb config $ ruby setup.rb setup $ ruby setup.rb install
# nor this The simplified do-it-yourself way
$ rake install
Contains all planned features except CVS like command handling
Fixed loading path using gems. Is now loaded by:
require 'rubygems' require 'commandline/optionparser'
First public release