taucmdr.cli package

Subpackages

Module contents

TAU Commander command line interface (CLI).

The TAU Commander CLI is composed of a single top-level command that invokes subcommands, much like git. For example, the command line tau project create my_new_project invokes the create subcommand of the project subcommand with the arguments my_new_project.

Every package in taucmdr.cli.commands is a TAU Commander subcommand. Modules in the package are that subcommand’s subcommands. This can be nested as deep as you like. Subcommand modules must have a COMMAND member which is an instance of a subclass of AbstractCommand.

exception taucmdr.cli.AmbiguousCommandError(value, matches, *hints)[source]

Bases: taucmdr.error.ConfigurationError

Indicates that a specified partial command is ambiguous.

message_fmt = "Command '%(value)s' is ambiguous.\n\n%(hints)s"
exception taucmdr.cli.UnknownCommandError(value, *hints)[source]

Bases: taucmdr.error.ConfigurationError

Indicates that a specified command is unknown.

message_fmt = '%(value)r is not a valid TAU command.\n\n%(hints)s'
taucmdr.cli._command_as_list(module_name)[source]

Converts a module name to a command name list.

Maps command module names to their command line equivilants, e.g. ‘taucmdr.cli.commands.target.create’ => [‘tau’, ‘target’, ‘create’]

Parameters:module_name (str) – Name of a module.
Returns:Strings that identify the command.
Return type:list
taucmdr.cli._get_commands(package_name)[source]

Returns a dictionary mapping commands to Python modules.

Given a root module name, return a dictionary that maps commands and their subcommands to Python modules. The special key __module__ maps to the command module. Other strings map to subcommands of the command.

Parameters:package_name (str) – A string naming the module to search for cli.
Returns:Strings mapping to dictionaries or modules.
Return type:dict

Example:

_get_commands('taucmdr.cli.commands.target') ==>
    {'__module__': <module 'taucmdr.cli.commands.target' from '/home/jlinford/workspace/taucmdr/packages/taucmdr/cli/commands/target/__init__.pyc'>,
     'create': {'__module__': <module 'taucmdr.cli.commands.target.create' from '/home/jlinford/workspace/taucmdr/packages/taucmdr/cli/commands/target/create.pyc'>},
     'delete': {'__module__': <module 'taucmdr.cli.commands.target.delete' from '/home/jlinford/workspace/taucmdr/packages/taucmdr/cli/commands/target/delete.pyc'>},
     'edit': {'__module__': <module 'taucmdr.cli.commands.target.edit' from '/home/jlinford/workspace/taucmdr/packages/taucmdr/cli/commands/target/edit.pyc'>},
     'list': {'__module__': <module 'taucmdr.cli.commands.target.list' from '/home/jlinford/workspace/taucmdr/packages/taucmdr/cli/commands/target/list.pyc'>}}
taucmdr.cli.command_from_module_name(module_name)[source]

Converts a module name to a command name string.

Maps command module names to their command line equivilants, e.g. ‘taucmdr.cli.commands.target.create’ => ‘tau target create’

Parameters:module_name (str) – Name of a module.
Returns:A string that identifies the command.
Return type:str
taucmdr.cli.commands_description(package_name='taucmdr.cli.commands')[source]

Builds listing of command names with short description.

Parameters:package_name (str) – A dot-seperated string naming the module to search for cli.
Returns:Help string describing all commands found at or below root.
Return type:str
taucmdr.cli.execute_command(cmd, cmd_args=None, parent_module=None)[source]

Import the command module and run its main routine.

Partial commands are allowed, e.g. cmd=[‘tau’, ‘cli’, ‘commands’, ‘app’, ‘cre’] will resolve to ‘taucmdr.cli.commands.application.create’. If the command can’t be found then the parent command (if any) will be invoked with the --help flag.

Parameters:
  • cmd (list) – List of strings identifying the command, i.e. from _command_as_list.
  • cmd_args (list) – Command line arguments to be parsed by command.
  • parent_module (str) – Dot-seperated name of the command’s parent.
Raises:
Returns:

Command return code.

Return type:

int

taucmdr.cli.find_command(cmd)[source]

Import the command module and return its COMMAND member.

Parameters:

cmd (list) – List of strings identifying the command, i.e. from _command_as_list.

Raises:
Returns:

Command object for the subcommand.

Return type:

AbstractCommand

taucmdr.cli.get_all_commands(package_name='taucmdr.cli.commands')[source]

Builds a list of all commands and subcommands.

Parameters:package_name (str) – A dot-separated string naming the module to search for cli.
Returns:List of modules corresponding to all commands and subcommands.
Return type:list