Package logilab :: Package common :: Module optparser

[frames] | no frames]

# Module optparser

source code

    Extend OptionParser with commands.

    Example:

    >>> parser = OptionParser()
    >>> parser.usage = '%prog COMMAND [options] <arg> ...'
    >>> parser.add_command('build', 'mymod.build')
    >>> parser.add_command('clean', run_clean, add_opt_clean)
    >>> run, options, args = parser.parse_command(sys.argv[1:])
    >>> return run(options, args[1:])

    With mymod.build that defines two functions run and add_options

Classes
| OptionParser