var cli struct {
Args []string `arg:"" optional:"" passthrough:""`
}
The first positional argument implies that it was preceded by --, so subsequent flags are not parsed.
If Kong parses cli 1 --unknown 3, it will populate Args with []string{"1", "--unknown", "3"}.
However, if Kong parses cli --unknown 2 3, it will fail saying that --unknown is an unrecognized flag.
Proposal
This commit changes the parser so that if an unknown flag could be treated as the first passthrough argument, it is.
After this change, if Kong parses cli --unknown 2 3, it will populate Args with []string{"--unknown", "2", "3"}.
Issue
Given a grammar like this:
The first positional argument implies that it was preceded by
--
, so subsequent flags are not parsed.If Kong parses
cli 1 --unknown 3
, it will populateArgs
with[]string{"1", "--unknown", "3"}
. However, if Kong parsescli --unknown 2 3
, it will fail saying that--unknown
is an unrecognized flag.Proposal
This commit changes the parser so that if an unknown flag could be treated as the first passthrough argument, it is.
After this change, if Kong parses
cli --unknown 2 3
, it will populateArgs
with[]string{"--unknown", "2", "3"}
.