@@ -173,6 +173,9 @@ MAIN:
|
|||||||
if flag.Short != 0 {
|
if flag.Short != 0 {
|
||||||
delete(seenFlags, "-"+string(flag.Short))
|
delete(seenFlags, "-"+string(flag.Short))
|
||||||
}
|
}
|
||||||
|
if negFlag := negatableFlagName(flag.Name, flag.Tag.Negatable); negFlag != "" {
|
||||||
|
delete(seenFlags, negFlag)
|
||||||
|
}
|
||||||
for _, aflag := range flag.Aliases {
|
for _, aflag := range flag.Aliases {
|
||||||
delete(seenFlags, "--"+aflag)
|
delete(seenFlags, "--"+aflag)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -467,6 +467,19 @@ func TestDuplicateNegatableLong(t *testing.T) {
|
|||||||
assert.EqualError(t, err, "<anonymous struct>.Two: duplicate negation flag --one")
|
assert.EqualError(t, err, "<anonymous struct>.Two: duplicate negation flag --one")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDuplicateNegatableFlagsInSubcommands(t *testing.T) {
|
||||||
|
cli2 := struct {
|
||||||
|
Sub struct {
|
||||||
|
Negated bool `negatable:"nope-"`
|
||||||
|
} `cmd:""`
|
||||||
|
Sub2 struct {
|
||||||
|
Negated bool `negatable:"nope-"`
|
||||||
|
} `cmd:""`
|
||||||
|
}{}
|
||||||
|
_, err := kong.New(&cli2)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestExistingNoFlag(t *testing.T) {
|
func TestExistingNoFlag(t *testing.T) {
|
||||||
var cli struct {
|
var cli struct {
|
||||||
Cmd struct {
|
Cmd struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user