Skip to content

Commit

Permalink
have --yaml-file option in mutual exclusive group with values and `…
Browse files Browse the repository at this point in the history
…--stdin`.

Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Dec 9, 2024
1 parent 07fb41b commit 853e7f2
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions ros2topic/ros2topic/verb/pub.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def add_arguments(self, parser, cli_name):
group.add_argument(
'--stdin', action='store_true',
help='Read values from standard input')
group.add_argument(
'--yaml-file', type=str, default=None,
help='YAML file that has message contents, '
'e.g STDOUT from ros2 topic echo <topic>')
parser.add_argument(
'-r', '--rate', metavar='N', type=positive_float, default=1.0,
help='Publishing rate in Hz (default: 1)')
Expand Down Expand Up @@ -98,10 +102,6 @@ def add_arguments(self, parser, cli_name):
'--keep-alive', metavar='N', type=positive_float, default=0.1,
help='Keep publishing node alive for N seconds after the last msg '
'(default: 0.1)')
parser.add_argument(
'--yaml-file', type=str, default=None,
help='YAML file that has message contents, prevails <values>. '
'e.g STDOUT from ros2 topic echo <topic>')
parser.add_argument(
'-n', '--node-name',
help='Name of the created publishing node')
Expand All @@ -124,12 +124,10 @@ def main(args):
if args.once:
times = 1

values = None
if not args.yaml_file:
if args.stdin:
values = collect_stdin()
else:
values = args.values
if args.stdin:
values = collect_stdin()
else:
values = args.values

with DirectNode(args, node_name=args.node_name) as node:
return publisher(
Expand Down

0 comments on commit 853e7f2

Please sign in to comment.