4 ms·
> Can you be explicit with what they are missing, I’m clearly missing it as well? There are two cases when a CLI program can print its usage 1. when the `--he
by tlamponi 3y ago
> Can you be explicit with what they are missing, I’m clearly missing it as well?
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.
- consp 3y ago3. With no input when input is required. 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...
- jakewins 3y agoYes, the OP is explicitly talking about case 1, and the quoted GNU docs are as well?