common.command.helper

Module with convenient function for defining user commands.

lmi.scripts.common.command.helper.make_list_command(func, name=None, columns=None, verify_func=None, transform_func=None)[source]

Create a command subclassed from LmiLister. Please refer to this class for detailed usage.

Parameters:
  • func (string or callable) – Contents of CALLABLE property.
  • name (string) – Optional name of resulting class. If not given, it will be made from the name of associated function.
  • columns (tuple) – Contents of COLUMNS property.
  • verify_func (callable) – Callable overriding py:meth:~.endpoint.LmiEndPointCommand.verify_options method.
  • transform_func (callable) – Callable overriding transform_options() method.
Returns:

Subclass of LmiLister.

Return type:

type

lmi.scripts.common.command.helper.register_subcommands(command_name, usage, command_map, fallback_command=None)[source]

Create a multiplexer command (a node in a tree of commands).

Parameters:
  • command_name (string) – Name of created command. The same as will be given on a command line.
  • usage (string) – Usage string parseable by docopt.
  • command_map (dictionary) – Dictionary of subcommands. Associates command names to their factories. It’s assigned to COMMANDS property.
  • fallback_command (LmiEndPointCommand) – Command factory used when no command is given on command line.
Returns:

Subclass of LmiCommandMultiplexer.

Return type:

type

Previous topic

common.command.endpoint

Next topic

common.command.lister

This Page