diff --git a/context.go b/context.go index 742bc9b..1e26ff5 100644 --- a/context.go +++ b/context.go @@ -793,8 +793,8 @@ func checkMissingFlags(flags []*Flag) error { missing = append(missing, flag.Summary()) } } - for _, flags := range xorGroup { - if len(flags) > 1 { + for xor, flags := range xorGroup { + if !xorGroupSet[xor] && len(flags) > 1 { missing = append(missing, strings.Join(flags, " or ")) } } diff --git a/kong_test.go b/kong_test.go index 482775d..e7568b2 100644 --- a/kong_test.go +++ b/kong_test.go @@ -932,6 +932,10 @@ func TestXorRequiredMany(t *testing.T) { _, err := p.Parse([]string{"--one"}) require.NoError(t, err) + p = mustNew(t, &cli) + _, err = p.Parse([]string{"--three"}) + require.NoError(t, err) + p = mustNew(t, &cli) _, err = p.Parse([]string{}) require.EqualError(t, err, "missing flags: --one or --two or --three")