MCPcopy Create free account
hub / github.com/coder/envbox / BoolVarP

Function BoolVarP

cli/cliflag/cliflag.go:139–153  ·  view source on GitHub ↗

BoolVarP sets a bool flag on the given flag set.

(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string, env string, def bool, usage string)

Source from the content-addressed store, hash-verified

137
138// BoolVarP sets a bool flag on the given flag set.
139func BoolVarP(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string, env string, def bool, usage string) {
140 val, ok := os.LookupEnv(env)
141 if !ok || val == "" {
142 flagset.BoolVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
143 return
144 }
145
146 valb, err := strconv.ParseBool(val)
147 if err != nil {
148 flagset.BoolVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
149 return
150 }
151
152 flagset.BoolVarP(ptr, name, shorthand, valb, fmtUsage(usage, env))
153}
154
155// DurationVarP sets a time.Duration flag on the given flag set.
156func DurationVarP(flagset *pflag.FlagSet, ptr *time.Duration, name string, shorthand string, env string, def time.Duration, usage string) {

Callers 2

dockerCmdFunction · 0.92
TestCliflagFunction · 0.92

Calls 1

fmtUsageFunction · 0.85

Tested by 1

TestCliflagFunction · 0.74