ComLine

Instances of this class parse and manage command line options. The public variable args is an array containing the unprocessed command line arguments (those that did not begin with '-').

Methods

__getitem__(self, key)

   def __getitem__(self, key):

Attempts to make the command line accessible as both an array and a dictionary. If key is an integer, returns a tuple containing either the indexed argument and None (if it is a non-option argument) or the value of the option and the ArgType object for the option (if it is a command line option).

If key is a string, it should be the name of a command line option and the value of that option will be returned. This will return None if the option is a legitimate option but was not specified on the command line.

If the value specified by the key does not exist, raises either an IndexError or a KeyError depending on the mode of addressing used.

__init__(self, arginfo, argv, helpPrefix)

   def __init__(self, arginfo, argv = None, helpPrefix = None):

Constructs a ComLine object from arginfo (a list of ArgType instances) and argv (list of command line arguments). If argv is not supplied, sys.argv is used.

_addArgType(self, v)

   def _addArgType(self, v):

_processExtended(self, args)

   def _processExtended(self, args):

_processOption(self, typeInfo, args)

   def _processOption(self, typeInfo, args):

_processShort(self, args)

   def _processShort(self, args):

help(self)

   def help(self):

Prints out a nicely formatted help message containing a description of each of the options. If helpPrefix was supplied during construction, prints this first. Otherwise, just prints the program name first.

optionsHelpToNML(self, cleanHelpText)

   def optionsHelpToNML(self, cleanHelpText = 0):

Returns a string representing the options help formatted in NML.

If cleanHelpText is true, escapes the special NML characters in the help text.

others(self)

   def others(self):

Constructs and returns a list of all non-option parameters.