Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: When a Grammar combines flags with passthrough args, see if an unrecognized flag may be treated as a positional argument #435

Commits on Jul 3, 2024

  1. ci: Add a test for positional args that are passthrough on a command …

    …that isn't passthrough
    boblail committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    c0e2806 View commit details
    Browse the repository at this point in the history

Commits on Jul 5, 2024

  1. fix: When a Grammar combines flags with passthrough args, see if an u…

    …nrecognized 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"}`.
    boblail committed Jul 5, 2024
    Configuration menu
    Copy the full SHA
    0f57080 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5aa7f97 View commit details
    Browse the repository at this point in the history