Module defining base command class for all possible commands of lmi meta-command.
Default formatting options overriden by options passed onc ommand-line and set in configuration file.
Abstract base class for all commands handling command line arguemtns. Instances of this class are organized in a tree with root element being the lmi meta-command (if not running in interactive mode). Each such instance can have more child commands if its LmiBaseCommand.is_end_point() method return False. Each has one parent command except for the top level one, whose parent property returns None.
Set of commands is organized in a tree, where each command (except for the root) has its own parent. is_end_point() method distinguish leaves from nodes. The path from root command to the leaf is a sequence of commands passed to command line.
If the LmiBaseCommand.has_own_usage() returns True, the parent command won’t process the whole command line and the remainder will be passed as a second argument to the LmiBaseCommand.run() method.
Parameters: |
|
---|
Abstract class method returning dictionary of child commands with structure:
{ "command-name" : cmd_factory, ... }
Dictionary contains just a direct children (commands, which may immediately follow this particular command on command line).
Convenience property calling get_cmd_name_parts() to obtain command path as a list of all preceding command names.
Return type: | list |
---|
Compose formatting options. Parent commands are queried for defaults. If command has no parent, default options will be taken from DEFAULT_FORMATTER_OPTIONS which are overriden by config settings.
Returns: | Arguments passed to formatter factory when formatter is for current command is constructed. |
---|---|
Return type: | dictionary |
Get name of this command as a list composed of names of all preceding commands since the top level one. When in interactive mode, only commands following the active one will be present.
Parameters: |
|
---|---|
Returns: | Command path. Returned list will always contain at least the name of this command. |
Return type: | list |
Return description for this command. This is usually a first line of documentation string of a class.
Return type: | string |
---|
Get command usage. Return value of this function is used by docopt parser as usage string. Command tree is traversed upwards until command with defined usage string is found. End point commands (leaves) require manually written usage, so the first command in the sequence of parents with own usage string is obtained and its usage returned. For nodes missing own usage string this can be generated based on its subcommands.
Parameters: | proper (boolean) – Says, whether the usage string written manually is required or not. It applies only to node (not a leaf) commands without its own usage string. |
---|
Returns: | True, if this command has its own usage string, which is returned by LmiBaseCommand.get_description(). Otherwise the parent command must be queried. |
---|---|
Return type: | boolean |
Returns: | True, if this command parses the rest of command line and can not have any child subcommands. |
---|---|
Return type: | boolean |
Handle the command line arguments. If this is not an end point command, it will pass the unhandled arguments to one of it’s child commands. So the arguments are processed recursively by the instances of this class.
Parameters: | args (list) – Arguments passed to the command line that were not yet parsed. It’s the contents of sys.argv (if in non-interactive mode) from the current command on. |
---|---|
Returns: | Exit code of application. This maybe also be a boolean value or None. None and True are treated as a success causing exit code to be 0. |
Return type: | integer |