NilBoolFlag defines a new flag with a bool pointer receiver. This is useful for differentiating between the flag being explicitly set to a false value and the flag not being passed at all.
(cmd *cobra.Command, p **bool, name string, shorthand string, usage string)
| 19 | // NilBoolFlag defines a new flag with a bool pointer receiver. This is useful for differentiating |
| 20 | // between the flag being explicitly set to a false value and the flag not being passed at all. |
| 21 | func NilBoolFlag(cmd *cobra.Command, p **bool, name string, shorthand string, usage string) *pflag.Flag { |
| 22 | f := cmd.Flags().VarPF(newBoolValue(p), name, shorthand, usage) |
| 23 | f.NoOptDefVal = "true" |
| 24 | return f |
| 25 | } |
| 26 | |
| 27 | // StringEnumFlag defines a new string flag that only allows values listed in options. |
| 28 | func StringEnumFlag(cmd *cobra.Command, p *string, name, shorthand, defaultValue string, options []string, usage string) *pflag.Flag { |
no test coverage detected