Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ros2lifecycle] Only return the state for the node requested #266

Merged
merged 3 commits into from
May 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ros2lifecycle/ros2lifecycle/verb/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@


class GetVerb(VerbExtension):
"""Get lifecycle state."""
"""Get lifecycle state for one or more nodes."""

def add_arguments(self, parser, cli_name): # noqa: D102
add_arguments(parser)
arg = parser.add_argument(
'node_name', nargs='?', help='Name of the ROS node')
'node_name', nargs='?', help='Name of the ROS node. '
'If no name is provided, then get the state for all nodes.')
arg.completer = NodeNameCompleter(
include_hidden_nodes_key='include_hidden_nodes')
parser.add_argument(
Expand All @@ -47,9 +48,12 @@ def main(self, *, args): # noqa: D102
if node_name:
if node_name not in node_names:
return 'Node not found'
nodes_to_query = [node_name]
else:
nodes_to_query = node_names

with DirectNode(args) as node:
states = call_get_states(node=node, node_names=node_names)
states = call_get_states(node=node, node_names=nodes_to_query)

# output exceptions
for node_name in sorted(states.keys()):
Expand Down