Skip to content

Commit

Permalink
Merge pull request #42785 from iocanel/fix-cli-plug-false-warning
Browse files Browse the repository at this point in the history
False error message on cli plug with flags
  • Loading branch information
gsmet authored Aug 27, 2024
2 parents 3051a69 + 7325188 commit a5fa272
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
.collect(Collectors.toList());
if (!unmatchedSubcommands.isEmpty()) {
missingCommand.append("-").append(unmatchedSubcommands.get(0));
return Optional.of(missingCommand.toString());
// We don't want the root itself to be added to the result
return Optional.of(stripRootPrefix(missingCommand.toString(), root.getCommandName() + "-"));
}

currentParseResult = currentParseResult.subcommand();
Expand All @@ -193,6 +194,14 @@ public Optional<String> checkMissingCommand(CommandLine root, String[] args) {
}
}

private static String stripRootPrefix(String command, String rootPrefix) {
if (!command.startsWith(rootPrefix)) {
return command;
}

return command.substring(rootPrefix.length());
}

@Override
public Integer call() throws Exception {
output.info("%n@|bold Quarkus CLI|@ version %s", Version.clientVersion());
Expand Down

0 comments on commit a5fa272

Please sign in to comment.