watson.console.runner

exception watson.console.runner.ConsoleError[source]

An error that should be raised from within the command.

class watson.console.runner.Runner(argv=None, commands=None)[source]

A command line runner that allows new commands to be added and run on demand.

Commands can be added either as a fully qualified name, or imported.

Example:

runner = Runner(commands=['module.commands.ACommand'])
runner()
__init__(argv=None, commands=None)[source]
add_command(command)[source]

Convenience method to add new commands after the runner has been initialized.

Parameters:command (string|class) – the command to add
add_commands(commands)[source]

Convenience method to add multiple commands.

Parameters:commands (list|tuple) – the commands to add
available_commands_usage[source]

Returns the usage text for all commands.

This is used when no commands have been specified.

commands[source]

A list of all commands added to the runner.

Returns:OrderedDict containing all the commands.
execute()[source]

Executes the specified command.

get_command(command_name)[source]

Returns an initialized command from the attached commands.

get_command_usage(command)[source]

Returns the usage string for an individual command.

name[source]

Returns the name of the script that runner was executed from.

usage[source]

Returns the usage text.

This is used when the -h or –help command is invoked.