File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ MAIN:
170170 if flag .Short != 0 {
171171 delete (seenFlags , "-" + string (flag .Short ))
172172 }
173+ for _ , aflag := range flag .Aliases {
174+ delete (seenFlags , "--" + aflag )
175+ }
173176 }
174177
175178 if err := validatePositionalArguments (node ); err != nil {
Original file line number Diff line number Diff line change @@ -1340,6 +1340,20 @@ func TestDuplicateAliases(t *testing.T) {
13401340 assert .EqualError (t , err , "<anonymous struct>.Flag2: duplicate flag --flag" )
13411341}
13421342
1343+ func TestSubCommandAliases (t * testing.T ) {
1344+ type SubC struct {
1345+ Flag1 string `aliases:"flag"`
1346+ }
1347+
1348+ cli1 := struct {
1349+ Sub1 SubC `cmd:"sub1"`
1350+ Sub2 SubC `cmd:"sub2"`
1351+ }{}
1352+
1353+ _ , err := kong .New (& cli1 )
1354+ assert .NoError (t , err , "dupe aliases shouldn't error if they're in separate sub commands" )
1355+ }
1356+
13431357func TestDuplicateAliasLong (t * testing.T ) {
13441358 cli2 := struct {
13451359 Flag string ``
You can’t perform that action at this time.
0 commit comments