You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if name == "help" || name == "h" { // special case for nice help message.
f.usage()
return false, ErrHelp
}
But, If the program is called with the wrong argument, I think that you should return explanation of usage and error.
Therefore, if you pass arguments that only "help" or "h", I think that f.usage () will be executed and (true, nil) will be returned.
I would like to know why it is implemented like this.
The text was updated successfully, but these errors were encountered:
zabio3
changed the title
In parseOne (), why (false, ErrHelp) is returned when only "- help" or "- h" is passed as an argument?
flag: In parseOne (), why (false, ErrHelp) is returned when only "- help" or "- h" is passed as an argument?
Mar 7, 2019
See https://golang.org/pkg/flag/#ErrorHandling; it's possible to configure a flagset to return errors. "The user requested the help text" is a kind of error, because the tool shouldn't continue as normal.
A custom flag.FlagSet returns a distinguished error, ErrHelp, when it sees the -help flag.
Where the code is written
But, If the program is called with the wrong argument, I think that you should return explanation of usage and error.
Therefore, if you pass arguments that only "help" or "h", I think that f.usage () will be executed and (true, nil) will be returned.
I would like to know why it is implemented like this.
The text was updated successfully, but these errors were encountered: