Feature: Add check for overlapping xor and and groups (#443)

* Docs: Clean and group description

* Feat: Add check for overlapping xor and and groups

Co-authored-by: inful <jone.marius@vign.es>

* Chore: Rewrite overlap err to avoid duplicated words

---------

Co-authored-by: inful <jone.marius@vign.es>
This commit is contained in:
Camilla
2024-09-10 13:01:12 +02:00
committed by GitHub
parent b297ae97f2
commit 7d84b95294
3 changed files with 44 additions and 1 deletions
+10
View File
@@ -1026,6 +1026,16 @@ func TestXorAnd(t *testing.T) {
assert.EqualError(t, err, "--hello and --one can't be used together, --hello and --two must be used together")
}
func TestOverLappingXorAnd(t *testing.T) {
var cli struct {
Hello bool `xor:"one" and:"two"`
One bool `xor:"one" and:"two"`
Two string `xor:"one" and:"two"`
}
_, err := kong.New(&cli)
assert.EqualError(t, err, "invalid xor and combination, one and two overlap with more than one: [hello one two]")
}
func TestXorRequired(t *testing.T) {
var cli struct {
One bool `xor:"one,two" required:""`