MCPcopy
hub / github.com/spf13/viper / BindPFlag

Function BindPFlag

viper.go:1072–1072  ·  view source on GitHub ↗

BindPFlag binds a specific key to a pflag (as used by cobra). Example (where serverCmd is a Cobra instance): serverCmd.Flags().Int("port", 1138, "Port to run Application server on") Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))

(key string, flag *pflag.Flag)

Source from the content-addressed store, hash-verified

1070// serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
1071// Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))
1072func BindPFlag(key string, flag *pflag.Flag) error { return v.BindPFlag(key, flag) }
1073
1074func (v *Viper) BindPFlag(key string, flag *pflag.Flag) error {
1075 if flag == nil {

Callers

nothing calls this directly

Calls 1

BindPFlagMethod · 0.80

Tested by

no test coverage detected