Proposal for "Console_Getargs"

» Metadata » Status
» Description
Command-line arguments parsing class.

This implementation was freely adapted from a Python module called getargs by Vinod Vijayarajan and a Perl CPAN module called Getopt::Simple by Ron Savage.

This class implements a Command Line Parser that applications can use to parse command line arguments in $_SERVER['argv'].
It provides more features than Console_Getopt. It also performs some arguments validation and is capable to return an help text based on the configuration it is given.

The class provides the following capabilities:

  1. Each command line option can take an arbitrary number of arguments.
  2. Makes the distinction between switches (options without arguments) and options with arguments.
  3. Recognizes 'single-argument-options' and 'default-if-set' options.
  4. Switches and options with arguments can be interleaved in the command line.
  5. You can specify the maximum and minimum number of arguments an option can take. Use -1 if you don't want to specify an upper bound.
  6. Specify default arguments to an option
  7. Short options can be more than one letter in length.
  8. A given option may be invoked by multiple names.
  9. Recognizes by default the --help, -h options
  10. Can return a formatted help text
  11. Arguments may be specified using the '=' syntax also.
» Dependencies » Links
  • PEAR.php
» Timeline » Changelog
  • First Draft: 2004-04-21
  • Proposal: 2004-04-21
  • Call for Votes: 2004-05-07