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

Parsing behaviour change with the v1.5.0 #475

Closed
oguzhand95 opened this issue Dec 2, 2024 · 1 comment
Closed

Parsing behaviour change with the v1.5.0 #475

oguzhand95 opened this issue Dec 2, 2024 · 1 comment

Comments

@oguzhand95
Copy link

oguzhand95 commented Dec 2, 2024

We are observing a behavior change with the new version v1.5.0. I am unsure whether it is intentional, hence creating this issue.

Given a CLI definition like following

var cli struct {
  Color *outputcolor.Level `short:"c"`
  Leftovers []string `arg:"" optional:""`
}

and arguments as -cfoo we see the following error value in v1.4.0:

err = {error | *kong.ParseError} 
 error = {error | *kong.unknownFlagError} unknown flag -f, did you mean one of "-h", "-c"?
 Context = {*kong.Context | 0x140000e6680} 

but there is no error reported with the v1.5.0.

I reproduced the issue at oguzhand95/kong-reprod.
The main branch is v1.4.0 and the PR updates the kong to v1.5.0 with failing tests.

kong/context.go

Lines 436 to 444 in 96647c3

case ShortFlagToken:
if err := c.parseFlag(flags, token.String()); err != nil {
if isUnknownFlagError(err) && positional < len(node.Positional) && node.Positional[positional].PassthroughMode == PassThroughModeAll {
c.scan.Pop()
c.scan.PushTyped(token.String(), PositionalArgumentToken)
} else {
return err
}
}

@alecthomas
Copy link
Owner

Thanks for the report, fixed in v1.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants