fix: bind verbose flag to root (#884)

This commit is contained in:
Luke Kingland 2022-03-09 04:02:06 +09:00 committed by GitHub
parent 917a8efdb2
commit 25524a1f84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -56,7 +56,6 @@ EXAMPLES
$ {{.Name}} invoke $ {{.Name}} invoke
For more examples, see '{{.Name}} <command> --help'.`, For more examples, see '{{.Name}} <command> --help'.`,
PreRunE: bindEnv("verbose"),
} }
// Environment Variables // Environment Variables
@ -68,6 +67,10 @@ EXAMPLES
// Flags // Flags
// persistent flags are available to all subcommands implicitly // persistent flags are available to all subcommands implicitly
cmd.PersistentFlags().BoolP("verbose", "v", false, "print verbose logs ($FUNC_VERBOSE)") cmd.PersistentFlags().BoolP("verbose", "v", false, "print verbose logs ($FUNC_VERBOSE)")
err := viper.BindPFlag("verbose", cmd.PersistentFlags().Lookup("verbose"))
if err != nil {
return cmd, err
}
// Version // Version
// Gather the statically-set version values (populated durin build) into // Gather the statically-set version values (populated durin build) into