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:

POSIX, :names => “-f”)

Gnu => %w[–file -f])

XTools => “-file”)


:names => %w(--file -file --files -files -f),
:arg_arity => [1,-1],
:arg_description => "file1 [file2, ...]"))

This last option prints:


    --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

Homepage: Download:


  • None

Currently optionparser is only available as a rubygem.

Via RubyGems

$ 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


0.5.1 06/17/2005

  • Contains all planned features except CVS like command handling

  • Fixed loading path using gems. Is now loaded by:

    require 'rubygems'
    require 'commandline/optionparser'
  • Updated documentation

0.5.0 06/07/2005

  • First public release