quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.86k stars 2.71k forks source link

Quarkus CLI reports `Unmatched argument at index 2` error when running a command that doesn't exist #41161

Open gastaldi opened 5 months ago

gastaldi commented 5 months ago

Describe the bug

When running a command that Quarkus doesn't understand, it throws a cryptic error from Picocli:

$ quarkus create ext abc -e                                                                        
Command quarkus-create-ext is not available, looking for available plugins ...
[ERROR] ❗  Command quarkus-create-ext is missing and can't be installed.
Creating an app (default project type, see --help).
picocli.CommandLine$UnmatchedArgumentException: Unmatched argument at index 2: 'abc'
    at io.quarkus.cli.common.OutputOptionMixin.throwIfUnmatchedArguments(OutputOptionMixin.java:154)
    at io.quarkus.cli.CreateApp.call(CreateApp.java:64)
    at io.quarkus.cli.CreateApp.call(CreateApp.java:22)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at io.quarkus.cli.Create.call(Create.java:35)
    at io.quarkus.cli.Create.call(Create.java:12)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at io.quarkus.cli.QuarkusCli.run(QuarkusCli.java:149)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:132)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
    at io.quarkus.cli.Main.main(Main.java:9)

[ERROR] ❗  Unable to create project: Unmatched argument at index 2: 'abc'

Expected behavior

It would be nice to display a better error message in this case

Actual behavior

Picocli error is shown

How to Reproduce?

Run quarkus create ext abc -e

Output of uname -a or ver

macOS m1

Output of java -version

JDK 17

Quarkus version or git rev

3.11.0

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.7

Additional information

No response

quarkus-bot[bot] commented 5 months ago

/cc @ebullient (cli), @maxandersen (cli)