Skip to content

Commit eee1699

Browse files
committed
Fixed arguments.CheckFlagsConflicts helper
Previously it would reject only if ALL the arguments in the given set are used. Now it rejects if AT LEAST TWO arguments of the given set are used.
1 parent 2fa1cf3 commit eee1699

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/cli/arguments/arguments.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ import (
2525

2626
// CheckFlagsConflicts is a helper function useful to report errors when more than one conflicting flag is used
2727
func CheckFlagsConflicts(command *cobra.Command, flagNames ...string) {
28+
var used []string
2829
for _, flagName := range flagNames {
29-
if !command.Flag(flagName).Changed {
30-
return
30+
if command.Flag(flagName).Changed {
31+
used = append(used, flagName)
3132
}
3233
}
33-
flags := "--" + strings.Join(flagNames, ", --")
34+
if len(used) <= 1 {
35+
return
36+
}
37+
flags := "--" + strings.Join(used, ", --")
3438
msg := i18n.Tr("Can't use the following flags together: %s", flags)
3539
feedback.Fatal(msg, feedback.ErrBadArgument)
3640
}

0 commit comments

Comments
 (0)