-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: flag: add SetHelpOutput to specify the destination for help explicitly #41523
Comments
Personally, I'm not sure that this is a convincing argument. Lots of programs print their help text to stderr, so if you want to use a pager, you have to know how to handle stderr anyway. In any POSIX-compatible shell, you can just do Finally, if you really do care about this detail, you could always just set your own usage func to print to stdout. |
There were objections to the change in exit status; see #37533 (comment) and the following discussion. I think there would be even stronger objections to changing from standard error to standard output. I agree that using standard output would make sense and would be consistent with the GNU coding standards (https://www.gnu.org/prep/standards/html_node/_002d_002dhelp.html). But I don't think we can change it now. |
Yes, I also don't want to put in a breaking change. I just want to be able to specify a destination optionally only for Also, I only want to change the output destination when |
Note that SetHelpOutput would be inappropriate when I would suggest that if you really want to implement -help, add that as a flag using the new flag.Func, and then it's easy to do:
at the top of your implementation. |
I also think that if As you suggested, defining |
I was pleased to see the exit code set to 0 when -h/--help was explicitly specified with Go 1.15 or later. ref. #37533.
I have one more request for -h/--help. It is that I want to be able to output usage to Stdout instead of Stderr only when the help flag is explicitly specified. This is useful when we want to pipe the output to a pager such as less.
I've made the following changes to allow us to specify the output destination for help. How about it?
cbb8882
The text was updated successfully, but these errors were encountered: