IsSet returns the string value of the flag and whether it was set.
(cmd *cobra.Command, name string)
| 35 | |
| 36 | // IsSet returns the string value of the flag and whether it was set. |
| 37 | func IsSet(cmd *cobra.Command, name string) (string, bool) { |
| 38 | flag := cmd.Flag(name) |
| 39 | if flag == nil { |
| 40 | return "", false |
| 41 | } |
| 42 | |
| 43 | return flag.Value.String(), flag.Changed |
| 44 | } |
| 45 | |
| 46 | // String sets a string flag on the given flag set. |
| 47 | func String(flagset *pflag.FlagSet, name, shorthand, env, def, usage string) { |