Defines command class used to nest multiple commands under one.
Base class for node commands. It consumes just part of command line arguments and passes the remainder to one of its subcommands.
Example usage:
class MyCommand(LmiCommandMultiplexer):
'''
My command description.
Usage: %(cmd)s mycommand (subcmd1 | subcmd2)
'''
COMMANDS = {'subcmd1' : Subcmd1, 'subcmd2' : Subcmd2}
Where Subcmd1 and Subcmd2 are some other LmiBaseCommand subclasses. Documentation string must be parseable with docopt.
Recognized properties:
- COMMANDS : dictionary
- property will be translated to LmiCommandMultiplexer.child_commands() class method by MultiplexerMetaClass.
Using metaclass: meta.MultiplexerMetaClass.
Abstract class method, that needs to be implemented in subclass. This is done by associated meta-class, when defining a command with assigned COMMANDS property.
Returns: | Dictionary of subcommand names with assigned command factories. |
---|---|
Return type: | dictionary |
This is overriden by MultiplexerMetaClass when the FALLBACK_COMMAND gets processed.
Returns: | Command factory invoked for missing command on command line. |
---|---|
Return type: | LmiEndPointCommand |
Handle optional parameters, retrieve desired subcommand name and pass the remainder of arguments to it.
Parameters: | args (list) – List of arguments with at least subcommand name. |
---|
Pass control to a subcommand identified by given name.
Parameters: |
|
---|---|
Returns: | Application exit code. |
Return type: | integer |