8000 Parsing behaviour change with the v1.5.0 · Issue #475 · alecthomas/kong · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Parsing behaviour change with the v1.5.0 #475
Closed
@oguzhand95

Description

@oguzhand95

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
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0