Skip to content

Commit c0a6b6f

Browse files
Fix topic argument in Discovery Server example (#5996) (#6015)
(cherry picked from commit fd1bb8f) Signed-off-by: Carlosespicur <[email protected]> Co-authored-by: Carlos Espinoza Curto <[email protected]>
1 parent 287e6f1 commit c0a6b6f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

examples/cpp/discovery_server/CLIParser.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,24 @@ class CLIParser
366366
// PubSub options
367367
else if (arg == "-t" || arg == "--topic")
368368
{
369-
if (config.entity == CLIParser::EntityKind::CLIENT_PUBLISHER ||
370-
config.entity == CLIParser::EntityKind::CLIENT_SUBSCRIBER)
369+
if (++i < argc)
371370
{
372-
config.pub_config.topic_name = argv[i];
373-
config.sub_config.topic_name = argv[i];
371+
if (config.entity == CLIParser::EntityKind::CLIENT_PUBLISHER ||
372+
config.entity == CLIParser::EntityKind::CLIENT_SUBSCRIBER)
373+
{
374+
config.pub_config.topic_name = argv[i];
375+
config.sub_config.topic_name = argv[i];
376+
}
377+
else
378+
{
379+
EPROSIMA_LOG_ERROR(CLI_PARSER,
380+
"wrong or missing entity for --topic argument: only available for publisher and subscriber");
381+
print_help(EXIT_FAILURE);
382+
}
374383
}
375384
else
376385
{
377-
EPROSIMA_LOG_ERROR(CLI_PARSER,
378-
"wrong or missing entity for --topic argument: only available for publisher and subscriber");
386+
EPROSIMA_LOG_ERROR(CLI_PARSER, "missing argument for " + arg);
379387
print_help(EXIT_FAILURE);
380388
}
381389
}

0 commit comments

Comments
 (0)