You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The title says almost all: I have a CLI app that is arranged as main command + subcommands. When I issue something like: java MainCommand help subCommand, the OS exit code is 0, not 2, despite both MainCommand.class and SubCommand are annotated with:
I think you are correct, and this is a bug in the implementation of picocli.CommandLine.HelpCommand.
This class currently implements Runnable.
To fix the issue, it should implement Callable<Integer> and should either return subcommand.getCommandSpec().exitCodeOnUsageHelp() if a subcommand was specified, or return parent.getCommandSpec().exitCodeOnUsageHelp() if not.
Will you be able to provide a pull request with tests for this?
Hi @remkop, I've tried to write a fix, but unfortunately, I don't have much time and I barely managed to change HelpCommand. It's hard to write a test and even without any changes, my clone doesn't build for me, mvn clean package gives me errors (starting with package org.junit does not exist), I can't use Gradle.
The title says almost all: I have a CLI app that is arranged as main command + subcommands. When I issue something like:
java MainCommand help subCommand
, the OS exit code is 0, not 2, despite both MainCommand.class and SubCommand are annotated with:@Command ( ... exitCodeOnUsageHelp = ExitCode.USAGE, exitCodeOnVersionHelp = ExitCode.USAGE)
when doing
java MainCommand -h
, it exits with 2 as expected. Unless I'm missing something, to me it is a bug.Until this is changed, it's possible to write a workaround like: in the static
main()
, check if the first argument is 'help'.The text was updated successfully, but these errors were encountered: