Skip to content
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

flag: make it possible to support -help in CommandLine flag set #30630

Open
alandonovan opened this issue Mar 6, 2019 · 1 comment
Open

flag: make it possible to support -help in CommandLine flag set #30630

alandonovan opened this issue Mar 6, 2019 · 1 comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@alandonovan
Copy link
Contributor

alandonovan commented Mar 6, 2019

A custom flag.FlagSet returns a distinguished error, ErrHelp, when it sees the -help flag (unless the FlagSet actually defines such a flag). However, the default flag set (CommandLine) has its error disposition set to ExitOnError, so the default Parse function (flag.Parse) never returns an error. An application can redefine the Usage operation of the CommandLine flag set so that it prints a help message, but the usage message is printed in many other contexts besides -help. The only way to support -help is thus to create a new FlagSet, or define a new boolean-style flag for -help that prints the help message and exits.

Can we make it easier for a small program to add a working -help feature? Perhaps the solution is better documentation.

@robpike

@robpike robpike self-assigned this Mar 6, 2019
@robpike
Copy link
Contributor

robpike commented Mar 8, 2019

Maybe all that's needed is a top-level Init that calls CommandLine.Init.

@julieqiu julieqiu added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 11, 2019
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 16, 2019
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 16, 2019
@rsc rsc added this to the Go1.13 milestone Apr 16, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants