Skip to content

Commit 853e7f2

Browse files
committed
have --yaml-file option in mutual exclusive group with values and --stdin.
Signed-off-by: Tomoya Fujita <[email protected]>
1 parent 07fb41b commit 853e7f2

File tree

1 file changed

+8
-10
lines changed
  • ros2topic/ros2topic/verb

1 file changed

+8
-10
lines changed

Diff for: ros2topic/ros2topic/verb/pub.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ def add_arguments(self, parser, cli_name):
7070
group.add_argument(
7171
'--stdin', action='store_true',
7272
help='Read values from standard input')
73+
group.add_argument(
74+
'--yaml-file', type=str, default=None,
75+
help='YAML file that has message contents, '
76+
'e.g STDOUT from ros2 topic echo <topic>')
7377
parser.add_argument(
7478
'-r', '--rate', metavar='N', type=positive_float, default=1.0,
7579
help='Publishing rate in Hz (default: 1)')
@@ -98,10 +102,6 @@ def add_arguments(self, parser, cli_name):
98102
'--keep-alive', metavar='N', type=positive_float, default=0.1,
99103
help='Keep publishing node alive for N seconds after the last msg '
100104
'(default: 0.1)')
101-
parser.add_argument(
102-
'--yaml-file', type=str, default=None,
103-
help='YAML file that has message contents, prevails <values>. '
104-
'e.g STDOUT from ros2 topic echo <topic>')
105105
parser.add_argument(
106106
'-n', '--node-name',
107107
help='Name of the created publishing node')
@@ -124,12 +124,10 @@ def main(args):
124124
if args.once:
125125
times = 1
126126

127-
values = None
128-
if not args.yaml_file:
129-
if args.stdin:
130-
values = collect_stdin()
131-
else:
132-
values = args.values
127+
if args.stdin:
128+
values = collect_stdin()
129+
else:
130+
values = args.values
133131

134132
with DirectNode(args, node_name=args.node_name) as node:
135133
return publisher(

0 commit comments

Comments
 (0)