https://www.gnu.org/prep/standards/html_node/_002d_002dhelp....
> The standard --help option should output brief documentation for how to invoke the program, on standard output, then exit successfully.
https://www.gnu.org/prep/standards/html_node/_002d_002dhelp....
> The standard --help option should output brief documentation for how to invoke the program, on standard output, then exit successfully.
OP says please have —help post to stdout, GNU guidance posted above says exact same thing?
There are two cases when a CLI program can print its usage
1. when the `--help` option, or often also the short-option `-h`, is passed to the program
2. When the user passes a wrong option to the program, where first the error is printed and then often also the general usage.
For 1. the output always should be on stdout, but for 2. the error should be on stderr, and it might be warranted that in that case the usage might be printed on stderr too, so that all is on the same stream.
Doing 2. is not a must though, one can also go for an output like:
> error message
> Try 'program-name --help' for more information
This avoids "hiding" the actual error in the often rather big amount of usage-text while still hinting how to get information about what options the program expects and/or accepts.This is a special case of 2, but is distinctly different since no context can be inferred.
In my opinion the program should fail successfully (as in non zero return) since no command was given. I'm highly annoyed when kubectl starts spuwing help text when I forget the command somewhere in a script.
Can we also find a "special place" for programs who always output the help text to stderr no matter what and have pages of options? I don't want to be redirecting before beging able to grep...