Skip to content

Commit

Permalink
[improve][cli] pulsar-perf: check for invalid CLI options (apache#18889)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgier authored and lifepuzzlefun committed Jan 10, 2023
1 parent 6258eb3 commit 6761520
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ public static void main(String[] args) throws Exception {
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
}

for (String arg : arguments.topic) {
if (arg.startsWith("-")) {
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
+ "please use a fully qualified topic name\n", arg, arg);
jc.usage();
PerfClientUtils.exit(-1);
}
}

if (arguments.topic != null && arguments.topic.size() != arguments.numTopics) {
// keep compatibility with the previous version
if (arguments.topic.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ public static void main(String[] args) throws Exception {
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
}

for (String arg : arguments.topics) {
if (arg.startsWith("-")) {
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
+ "please use a fully qualified topic name\n", arg, arg);
jc.usage();
PerfClientUtils.exit(-1);
}
}

if (arguments.topics != null && arguments.topics.size() != arguments.numTopics) {
// keep compatibility with the previous version
if (arguments.topics.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ public static void main(String[] args) throws Exception {
PerfClientUtils.exit(-1);
}

for (String arg : arguments.topic) {
if (arg.startsWith("-")) {
System.out.printf("invalid option: '%s'\nTo use a topic with the name '%s', "
+ "please use a fully qualified topic name\n", arg, arg);
jc.usage();
PerfClientUtils.exit(-1);
}
}

if (arguments.topic != null && arguments.topic.size() != arguments.numTopics) {
// keep compatibility with the previous version
if (arguments.topic.size() == 1) {
Expand Down

0 comments on commit 6761520

Please sign in to comment.