-
Notifications
You must be signed in to change notification settings - Fork 141
Description
When the user enters a command that doesn't exist (e.g. mis-typed a command), an exception is thrown.
Exception in thread "main" io.airlift.airline.ParseArgumentsUnexpectedException: Found unexpected parameters: [blah, something]
at io.airlift.airline.Cli.validate(Cli.java:148)
at io.airlift.airline.Cli.parse(Cli.java:116)
at io.airlift.airline.Cli.parse(Cli.java:97)
Since the end-user mistyping a command is an obvious use case, I'm assuming I've done something wrong. I've set Help as the default command, but I guess that isn't it.
Cli.CliBuilder<Runnable> builder = Cli.<Runnable>builder("muse")
.withDescription("Muse command-line tools")
.withDefaultCommand(Help.class)
.withCommands(Help.class)
.withCommands(implementors);
Cli<Runnable> muse_parser = builder.build();
muse_parser.parse(args).run();
My fix thus far is to catch the exception and run the Help command by re-parsing an empty command line. That seems like a hack. new Help().run() threw an exception, too, so that wasn't any better.
I feel like I'm missing an obvious solution, since none of the examples include catching an exception.
TIA!
Chris