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

Function Bool

cli/cliflag/cliflag.go:122–136  ·  view source on GitHub ↗
(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string)

Source from the content-addressed store, hash-verified

120}
121
122func Bool(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string) {
123 val, ok := os.LookupEnv(env)
124 if !ok || val == "" {
125 flagset.BoolP(name, shorthand, def, fmtUsage(usage, env))
126 return
127 }
128
129 valb, err := strconv.ParseBool(val)
130 if err != nil {
131 flagset.BoolP(name, shorthand, def, fmtUsage(usage, env))
132 return
133 }
134
135 flagset.BoolP(name, shorthand, valb, fmtUsage(usage, env))
136}
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) {

Callers

nothing calls this directly

Calls 1

fmtUsageFunction · 0.85

Tested by

no test coverage detected