ros2cli.command package
Submodules
Module contents
- class ros2cli.command.CommandExtension
Bases:
object
The extension point for ‘command’ extensions.
The following properties must be defined: * NAME (will be set to the entry point name)
The following methods must be defined: * main
The following methods can be defined: * add_arguments
- EXTENSION_POINT_VERSION = '0.1'
- NAME = None
- add_arguments(parser, cli_name, *, argv=None)
- main(*, parser, args)
- class ros2cli.command.MutableString
Bases:
object
Behave like str with the ability to change the value of an instance.
- class ros2cli.command.SuppressUsageOutput(parsers)
Bases:
object
Context manager to suppress help action during parse_known_args.
- ros2cli.command.add_subparsers(parser, cli_name, dest, command_extensions, hide_extensions=None, required=True)
Create argparse subparser for each extension.
The
cli_name
is used for the title and description of theadd_subparsers
function call.For each extension a subparser is created. If the extension has an
add_arguments
method it is being called.This method is deprecated. Use the function
add_subparsers_on_demand
instead. Their signatures are almost identical. Instead of passing the extensions the new function expects the group name of these extensions.- Parameters:
parser (
argparse.ArgumentParser
) – the parent argument parsercli_name (str) – name of the command line command to which the subparsers are being added
dest (str) – name of the attribute under which the selected extension will be stored
command_extensions (dict) – dict of command extensions by their name where each contributes a command with specific arguments
- ros2cli.command.add_subparsers_on_demand(parser, cli_name, dest, group_name, hide_extensions=None, required=True, argv=None)
Create argparse subparser for each extension on demand.
The
cli_name
is used for the title and description of theadd_subparsers
function call.For each extension a subparser is created is necessary. If no extension has been selected by command line arguments all first level extension must be loaded and instantiated. If a specific extension has been selected by command line arguments the sibling extension can be skipped and only that one extension (as well as potentially its recursive extensions) are loaded and instantiated. If the extension has an
add_arguments
method it is being called.- Parameters:
parser (
argparse.ArgumentParser
) – the parent argument parsercli_name (str) – name of the command line command to which the subparsers are being added
dest (str) – name of the attribute under which the selected extension will be stored
group_name (str) – the name of the
entry_point
group identifying the extensions to be addedhide_extensions (list) – an optional list of extension names which should be skipped
required (bool) – a flag if the command is a required argument
argv (list) – the list of command line arguments (default:
sys.argv
)
- ros2cli.command.get_command_extensions(group_name, *, exclude_names=None)