Commands in ros2cli use different option names to include hidden entities. For example, ros2 node list and ros2 lifecycle nodes use -a / --all, ros2 node info uses --include-hidden, and other commands use --include-hidden-nodes, --include-hidden-topics, or --include-hidden-services.
Add --all (and -a) as an alias to the following files so users can pass --all consistently across commands:
ros2node/ros2node/verb/info.py
ros2lifecycle/ros2lifecycle/verb/get.py
ros2lifecycle/ros2lifecycle/verb/set.py
ros2param/ros2param/verb/delete.py
ros2param/ros2param/verb/describe.py
ros2param/ros2param/verb/dump.py
ros2param/ros2param/verb/get.py
ros2param/ros2param/verb/list.py
ros2param/ros2param/verb/load.py
ros2param/ros2param/verb/set.py
ros2topic/ros2topic/command/topic.py
ros2topic/ros2topic/verb/find.py
ros2topic/ros2topic/verb/list.py
ros2service/ros2service/command/service.py
ros2service/ros2service/verb/find.py
ros2service/ros2service/verb/list.py
(Note: Skip ros2lifecycle/ros2lifecycle/verb/list.py because it already uses -a / --all to display all transitions.)
Example: How to add the alias
Keep the existing long option first (so argparse keeps the same args.<attribute> destination name) and add '--all' and '-a':
# Before:
parser.add_argument(
'--include-hidden-topics', action='store_true',
help='Consider hidden topics as well')
# After:
parser.add_argument(
'--include-hidden-topics', '--all', action='store_true',
help='Consider hidden topics as well')
Example: How to add a test
You can test argument parsing in the package's test/ folder using argparse.ArgumentParser:
import argparse
from ros2topic.verb.list import ListVerb
def test_list_all_alias():
parser = argparse.ArgumentParser()
verb = ListVerb()
verb.add_arguments(parser, 'ros2 topic list')
args = parser.parse_args(['--all'])
assert args.include_hidden_topics is True
Commands in
ros2cliuse different option names to include hidden entities. For example,ros2 node listandros2 lifecycle nodesuse-a/--all,ros2 node infouses--include-hidden, and other commands use--include-hidden-nodes,--include-hidden-topics, or--include-hidden-services.Add
--all(and-a) as an alias to the following files so users can pass--allconsistently across commands:ros2node/ros2node/verb/info.pyros2lifecycle/ros2lifecycle/verb/get.pyros2lifecycle/ros2lifecycle/verb/set.pyros2param/ros2param/verb/delete.pyros2param/ros2param/verb/describe.pyros2param/ros2param/verb/dump.pyros2param/ros2param/verb/get.pyros2param/ros2param/verb/list.pyros2param/ros2param/verb/load.pyros2param/ros2param/verb/set.pyros2topic/ros2topic/command/topic.pyros2topic/ros2topic/verb/find.pyros2topic/ros2topic/verb/list.pyros2service/ros2service/command/service.pyros2service/ros2service/verb/find.pyros2service/ros2service/verb/list.py(Note: Skip
ros2lifecycle/ros2lifecycle/verb/list.pybecause it already uses-a/--allto display all transitions.)Example: How to add the alias
Keep the existing long option first (so
argparsekeeps the sameargs.<attribute>destination name) and add'--all'and'-a':Example: How to add a test
You can test argument parsing in the package's
test/folder usingargparse.ArgumentParser: