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

Load a message/request/goal from standard input #844

Merged
merged 3 commits into from Aug 3, 2023

Conversation

ymd-stella
Copy link
Contributor

Resolve #842

Add option --stdin to pass yaml from standard input.
The last positional argument and the new option --stdin are mutually_exclusive_group.

The change requires that the send_goal argument goal be optional.

Signed-off-by: ymd-stella <world.applepie@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this looks good to me. I've left one suggestion for improvement.

Comment on lines 61 to 68
if args.stdin:
lines = b""
while True:
line = sys.stdin.buffer.readline()
if not line:
break
lines += line
args.goal = lines
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have this exact same stanza in multiple files, I'm going to suggest that we move this into a function in https://github.com/ros2/ros2cli/blob/rolling/ros2cli/ros2cli/helpers.py . That way we'll have less duplicated code. Then this will be something like:

Suggested change
if args.stdin:
lines = b""
while True:
line = sys.stdin.buffer.readline()
if not line:
break
lines += line
args.goal = lines
if args.stdin:
arg.goal = utils.collect_stdin()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is getting closer, a few more things to fix.

ros2action/ros2action/verb/send_goal.py Outdated Show resolved Hide resolved
ros2action/ros2action/verb/send_goal.py Outdated Show resolved Hide resolved
ros2action/ros2action/verb/send_goal.py Outdated Show resolved Hide resolved
ros2cli/ros2cli/helpers.py Outdated Show resolved Hide resolved
ros2service/ros2service/verb/call.py Outdated Show resolved Hide resolved
ros2service/ros2service/verb/call.py Outdated Show resolved Hide resolved
ros2service/ros2service/verb/call.py Outdated Show resolved Hide resolved
ros2topic/ros2topic/verb/pub.py Outdated Show resolved Hide resolved
ros2topic/ros2topic/verb/pub.py Outdated Show resolved Hide resolved
Signed-off-by: ymd-stella <world.applepie@gmail.com>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thank you!

@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

ros2cli/ros2cli/helpers.py Outdated Show resolved Hide resolved
Signed-off-by: ymd-stella <world.applepie@gmail.com>
@clalancette
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette clalancette merged commit 351ef3c into ros2:rolling Aug 3, 2023
3 checks passed
@ymd-stella ymd-stella deleted the feature/stdin branch August 3, 2023 23:49
ymd-stella added a commit to ymd-stella/ros2cli that referenced this pull request Aug 4, 2023
* Load a message/request/goal from standard input

Signed-off-by: ymd-stella <world.applepie@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load a message or request from a yaml file (or standard input)
2 participants