-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: When a Grammar combines flags with passthrough args, see if an u…
…nrecognized flag may be treated as a positional argument (#435) * ci: Add a test for positional args that are passthrough on a command that isn't passthrough * fix: When a Grammar combines flags with passthrough args, see if an unrecognized flag may be treated as a positional argument Given a grammar like this: ```golang 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. 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"}`. * ci: Skip the `maintidx` linter for `trace()`
- Loading branch information
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters