jcommander
jcommander copied to clipboard
Usage info should be sent to stderr, not stdout
Currently the usage info is sent to stdout. It should be sent to stderr, by convention.
i would prefer stdout/stderr to be configurable.
i think using java.io.Console in JCommander.getConsole() hinders such implementation, because java.io.Console is initialized with FileDescriptor.out and it is hard coded 😢
Picocli handles this correctly out of the box:
when the user specified invalid input, the error message and usage help should be printed to stderr, but when the user requests help with <cmd> --help
, the usage help should be printed to stdout so users can pipe the output to tools like grep
and less
.