From 14b98e3e5f572f1b8730185f8ba4ce973c9d7dc2 Mon Sep 17 00:00:00 2001 From: Ioannis Canellos Date: Tue, 27 Aug 2024 13:03:59 +0300 Subject: [PATCH] fix: false error message on cli plug with flags --- devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java b/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java index a618a7ae3273e..c39ea351ecbcc 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java @@ -12,6 +12,7 @@ import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.Supplier; +import java.util.regex.Pattern; import java.util.stream.Collectors; import jakarta.inject.Inject; @@ -176,7 +177,8 @@ public Optional 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(missingCommand.toString().replaceFirst(Pattern.quote(root.getCommandName() + "-"), "")); } currentParseResult = currentParseResult.subcommand();