diff --git a/ros2topic/ros2topic/verb/pub.py b/ros2topic/ros2topic/verb/pub.py index a93f909b8..f280f1bc7 100644 --- a/ros2topic/ros2topic/verb/pub.py +++ b/ros2topic/ros2topic/verb/pub.py @@ -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 ') parser.add_argument( '-r', '--rate', metavar='N', type=positive_float, default=1.0, help='Publishing rate in Hz (default: 1)') @@ -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 . ' - 'e.g STDOUT from ros2 topic echo ') parser.add_argument( '-n', '--node-name', help='Name of the created publishing node') @@ -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(