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
{{ message }}
Repository navigation
When using "help <SubCommand>", the exit code is 0, despite exitCodeOnUsageHelp = ExitCode.USAGE #2355
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.
Activity
remkop commentedon Dec 9, 2024
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 eitherreturn subcommand.getCommandSpec().exitCodeOnUsageHelp()if a subcommand was specified, orreturn parent.getCommandSpec().exitCodeOnUsageHelp()if not.Will you be able to provide a pull request with tests for this?
HelpCommand, trying to fix remkop#2355 [ci skip]
marco-brandizi commentedon Dec 11, 2024
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 packagegives me errors (starting with package org.junit does not exist), I can't use Gradle.remkop commentedon Dec 20, 2024
Note to self:
[remkop#2355] Bugfix: The built-in `help` subcommand should return th…
[#2355] fix Groovy test for exit code of the help subcommand