Merge pull request #9614 from prezha/fix-help-flag

fix help flag 'pflag: help requested' error
pull/9618/head
priyawadhwa 2020-11-06 11:11:48 -08:00 committed by GitHub
commit ac898f8c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -127,6 +127,8 @@ func setFlags() {
// "Flag parsing stops just before the first non-flag argument" (ref: https://pkg.go.dev/flag#hdr-Command_line_flag_syntax)
pflag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
// avoid 'pflag: help requested' error, as help will be defined later by cobra cmd.Execute()
pflag.BoolP("help", "h", false, "")
pflag.Parse()
// set default flag value for logtostderr and alsologtostderr but don't override user's preferences