One-line command description here.
>>> c = Command()
>>> print c.help()
usage: be command [options]
Options:
-h, --help Print a help message.
--complete Print a list of possible completions.
A detailed help message.
Methods
cleanup() | |
complete([argument, fragment]) | |
help(*args) | |
run([options, args]) | |
usage() |
Methods
cleanup() | |
setup_command(command) |
Methods
validate() |
Methods
dedent() | |
expand_default(option) | |
format_description(description) | |
format_epilog(epilog) | |
format_heading(heading) | |
format_option(option) | |
format_option_strings(option) | Return a comma-separated list of option strings & metavariables. |
format_usage(usage) | |
indent() | |
option_help() | |
set_long_opt_delimiter(delim) | |
set_parser(parser) | |
set_short_opt_delimiter(delim) | |
store_option_strings(parser) |
Methods
cleanup() | |
setup_command(command) |
Methods
cleanup() | |
get_bugdir() | Callback for use by commands that need it. |
get_storage() | Callback for use by commands that need it. |
get_unconnected_storage() | Callback for use by commands that need it. |
set_bugdir(bugdir) | |
set_storage(storage) | |
set_unconnected_storage(unconnected_storage) | |
setup_command(command) |
Callback for use by commands that need it.
Callback for use by commands that need it.
Callback for use by commands that need it.
The returned Storage instance is may actually be connected, but commands that make use of the returned value should only make use of non-connected Storage methods. This is mainly intended for the init command, which calls Storage.init().
>>> s = StringInputOutput()
>>> s.set_stdin('hello')
>>> s.stdin.read()
'hello'
>>> s.stdin.read()
''
>>> print >> s.stdout, 'goodbye'
>>> s.get_stdout()
'goodbye\n'
>>> s.get_stdout()
''
Also works with unicode strings
>>> s.set_stdin(u'hello')
>>> s.stdin.read()
u'hello'
>>> print >> s.stdout, u'goodbye'
>>> s.get_stdout()
u'goodbye\n'
Methods
cleanup() | |
get_stdout() | |
set_stdin(stdin_string) | |
setup_command(command) |
Methods
cleanup() | |
help() | |
run(command[, options, args]) | |
setup_command(command) |
Retrieves the module for a user command
>>> try:
... get_command('asdf')
... except UnknownCommand, e:
... print e
Unknown command 'asdf'
>>> repr(get_command('list')).startswith("<module 'libbe.command.list' from ")
True
Retrieves a command class from a module.
>>> import_xml_mod = get_command('import-xml')
>>> import_xml = get_command_class(import_xml_mod, 'import-xml')
>>> repr(import_xml)
"<class 'libbe.command.import_xml.Import_XML'>"
>>> import_xml = get_command_class(command_name='import-xml')
>>> repr(import_xml)
"<class 'libbe.command.import_xml.Import_XML'>"
Little hack to replicate >>> import sys >>> def real_modname_to_command_name(modname): ... mod = libbe.util.plugin.import_by_name( ... ‘libbe.command.%s’ % modname) ... attrs = [getattr(mod, name) for name in dir(mod)] ... commands = [] ... for attr_name in dir(mod): ... attr = getattr(mod, attr_name) ... try: ... if issubclass(attr, Command): ... commands.append(attr) ... except TypeError, e: ... pass ... if len(commands) == 0: ... raise Exception(‘No Command classes in %s’ % dir(mod)) ... return commands[0].name >>> real_modname_to_command_name(‘new’) ‘new’ >>> real_modname_to_command_name(‘import_xml’) ‘import-xml’