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

Function IntVarP

cli/cliflag/cliflag.go:106–120  ·  view source on GitHub ↗

IntVarP sets a uint8 flag on the given flag set.

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

Source from the content-addressed store, hash-verified

104
105// IntVarP sets a uint8 flag on the given flag set.
106func IntVarP(flagset *pflag.FlagSet, ptr *int, name string, shorthand string, env string, def int, usage string) {
107 val, ok := os.LookupEnv(env)
108 if !ok || val == "" {
109 flagset.IntVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
110 return
111 }
112
113 vi64, err := strconv.Atoi(val)
114 if err != nil {
115 flagset.IntVarP(ptr, name, shorthand, def, fmtUsage(usage, env))
116 return
117 }
118
119 flagset.IntVarP(ptr, name, shorthand, vi64, fmtUsage(usage, env))
120}
121
122func Bool(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string) {
123 val, ok := os.LookupEnv(env)

Callers 2

dockerCmdFunction · 0.92
TestCliflagFunction · 0.92

Calls 1

fmtUsageFunction · 0.85

Tested by 1

TestCliflagFunction · 0.74