Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False error message on cli plug with flags #42785

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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