mirror of https://github.com/spf13/cobra.git
simplify mark flags
This commit is contained in:
parent
b19c5d4ab1
commit
0967a36905
|
@ -58,7 +58,7 @@ func MarkFlagRequired(flags *pflag.FlagSet, name string) error {
|
||||||
// and causes your command to report an error if invoked without any of the flags.
|
// and causes your command to report an error if invoked without any of the flags.
|
||||||
func MarkFlagsRequired(flags *pflag.FlagSet, names ...string) error {
|
func MarkFlagsRequired(flags *pflag.FlagSet, names ...string) error {
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
if err := flags.SetAnnotation(name, BashCompOneRequiredFlag, []string{"true"}); err != nil {
|
if err := MarkFlagRequired(flags, name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue