File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -383,9 +383,13 @@ func (c *Context) trace(node *Node) (err error) { //nolint: gocyclo
383
383
384
384
// Indicates end of parsing. All remaining arguments are treated as positional arguments only.
385
385
case v == "--" :
386
- c .scan .Pop ()
387
386
c .endParsing ()
388
387
388
+ // Pop the -- token unless the next positional argument accepts passthrough arguments.
389
+ if ! (positional < len (node .Positional ) && node .Positional [positional ].Passthrough ) {
390
+ c .scan .Pop ()
391
+ }
392
+
389
393
// Long flag.
390
394
case strings .HasPrefix (v , "--" ):
391
395
c .scan .Pop ()
Original file line number Diff line number Diff line change @@ -1743,10 +1743,16 @@ func TestPassthroughArgs(t *testing.T) {
1743
1743
[]string {"something" },
1744
1744
},
1745
1745
{
1746
- "DashDashBeforeRecognizedFlag" ,
1746
+ "DashDashBetweenArgs" ,
1747
+ []string {"foo" , "--" , "bar" },
1748
+ "" ,
1749
+ []string {"foo" , "--" , "bar" },
1750
+ },
1751
+ {
1752
+ "DashDash" ,
1747
1753
[]string {"--" , "--flag" , "foobar" },
1748
1754
"" ,
1749
- []string {"--flag" , "foobar" },
1755
+ []string {"--" , "-- flag" , "foobar" },
1750
1756
},
1751
1757
{
1752
1758
"UnrecognizedFlagAndArgs" ,
You can’t perform that action at this time.
0 commit comments