watson.console.command

class watson.console.command.Base[source]

The base command that outlines the required structure for a console command.

Help is automatically invoked when the -h or –help option is used.

http://docs.python.org/dev/library/argparse.html#the-add-argument-method

Example:

# can be executed by `script.py mycommand`
class MyCommand(BaseCommand):
    name = 'mycommand'

    def execute(self):
        return True

# can be executed by `script.py mycommand -t something`
class MyCommand(BaseCommand):
    name = 'mycommand'
    arguments = [
        (['-t', '--test'], {'help': 'Do something with -t'})
    ]

    def execute(self):
        return True if self.parsed_args.t else False

# can be executed by `script.py mycommand something`
class MyCommand(BaseCommand):
    name = 'mycommand'
    arguments = [
        {'dest': 'argument1', 'help': 'This is the help for the argument'}
    ]

    def execute(self):
        return True if self.parsed_args.argument1 else False
parsed_args[source]

Returns the parsed arguments.

Returns:list|dict depending on whether or not there have been named arguments.
watson.console.command.find_commands_in_module(module)[source]

Retrieves a list of all commands within a module.

Returns:A list of commands from the module.