James Gardner: Home > Work > Code > CommandTool > 0.3.2 > API Documentation

CommandTool v0.3.2 documentation

API Documentation

Tools to write command line interfaces with sub-commands

exception commandtool.ManError
exception commandtool.OptionConfigurationError
commandtool.build_help(options, aliases, program, usage)
commandtool.extract_metavars(list_of_option_sets)
commandtool.get_text(nodelist)
commandtool.handle_html_config_row(row)
commandtool.handle_program(command_handler_factories, option_sets, aliases, program_options, command_options, command, args, program_name, help=None, existing=None)

usage: %(program)s [PROGRAM_OPTIONS] COMMAND [OPTIONS] ARGS

Try `%(program)s COMMAND –help’ for help on a specific command.

commandtool.makeHandler(handler)

Used in these files to make a handler:

./CommandTool/trunk/commandtool/help.py ./CommandTool/trunk/example/find/find.py ./CommandTool/trunk/doc/source/introduction.rst

commandtool.make_man_page(program_name, program_description=None, email=None, organization=None, address=None, date=None, copyright=None, version=None, section=1, group='text processing', synopsis=None, description=None, options=None, rest=None)
Build a reStructuredText page in a format capable of being converted to man format by rst2man.py
commandtool.option_names_from_option_list(option_list)
commandtool.parse_command_line(option_sets, aliases=None, sys_args=None)
commandtool.parse_html_config(filename)

Looks for a config file in the form of an HTML table where the first column specifies the metavars, the second column gives a descritption and the third column contains the values.

Returns a dictionary of metavars and their corresponding values, the descriptions are ignored.

The HTML file must contain a table strictly with three columns and no colspans. The table must be started with precisely these characters: <table class="commandtool-config" `` and ended with precisely these characters: ``</table>. Between these two tags the content must also be valid XML.

eg:

<table class="commandtool-config" border="0">
<tr>
    <td class="metavar"><tt>START_DIRECTORY</tt></td>
    <td>The directory to begin the search</td>
    <td>/home/james</td>
</tr>
</table>

Any HTML tags within the table cells are stripped.

commandtool.set_error_on(command_options, allowed)
commandtool.strip_docsting(docstring, tabstop=4)
commandtool.strip_docstring(docstring, tabstop=4)
commandtool.uniform_path(path)
James Gardner: Home > Work > Code > CommandTool > 0.3.2 > API Documentation