Home | Trees | Indices | Help |
---|
|
Class for the functionality that parses the command line.
The command parser is used to easily specify a list of command line options and commands to be parsed from an argument list.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Create a new command parser. 'name' -- The name of the executable that we are currently using. This will normally be argv[0]. 'options' -- A list of 4-tuples specifying options that you wish this parser to accept. The 4-tuple has the following form: (short_form, long_form, options, description). 'short_form' must be exactly one character. 'long_form' must be specified for every option in the list. 'arg_name' is a string representing the name of the argument that is passed to this option. If it is 'None,' then this option doesn't take an argument. 'description' is a string describing the option. 'commands' -- A list of 5-tuples specifying commands to be accepted after the command line options. The 5-tuple has the form '(name, short_description, args_string, long_description, options)'. 'name' -- The string for the command. 'short_description' -- A short description of the command to be printed out in general help. 'args_string' -- The string that will be printed after the command in the command specific help. 'long_description' -- The long description to be printed out in the command specfic help. 'options' -- A list of 4-tuples of the same form as the 'options' described above. 'conflicting_options' -- A sequence of sets of conflicting options. Each element is a sequence of option specifiers in the same form as 'options', above. |
Check that a list of options 4-tuples is correct. 'options' -- A list of 4-tuples as described above. returns -- 1 if the options are all valid, 0 otherwise. |
Build a getopt list for the long options. 'options' -- A list of 4-tuples as described above. returns -- A list to be passed to getopt to parse long options. |
Build a getopt string for the options passed in. 'options' -- A list of 4-tuples as described above. returns -- A string to be passed to getopt to parse the options. |
Return a string that is the basic help for options. options -- A list of options to get the help string for. returns -- A string to be printed for the options. |
Return a string that is the basic help for the commands. returns -- A string to be printed with basic functionality of arguments and commands. |
Return a string that is the help for a specific command. command -- A string of the command that you want help for. returns -- A string of help for a given command. |
Parse a command line. 'argv' -- A string containing the command line starting with argv[1]. It should not contain the name of the executed program. returns -- A 4-tuple of the options given, the command given, the command options, and the command arguments. Its form is this: (options, command, command_options, command_args). 'options' is a list of 2-tuples indicating each option specified and the argument given to that option (if applicable). 'command' is the command given. 'command_options' is a list of 2-tuples indicating each option given to the command and its possible argument. 'command_args' is a list of arguments as given to the command. If no command is given, then the function will return '' for the command, [] for the arguments, and [] for the command options. raises -- 'CommandError' if the command is invalid. |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Dec 23 12:30:40 2011 | http://epydoc.sourceforge.net |