(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string)
| 120 | } |
| 121 | |
| 122 | func 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. |
| 139 | func BoolVarP(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string, env string, def bool, usage string) { |
nothing calls this directly
no test coverage detected