Skip to content

fix: generate suggestions for invalid arg instead of args[0] in OnlyValidArgs - #2489

Open
aoright wants to merge 1 commit into
spf13:mainfrom
aoright:fix/only-valid-args-suggestion-target
Open

fix: generate suggestions for invalid arg instead of args[0] in OnlyValidArgs#2489
aoright wants to merge 1 commit into
spf13:mainfrom
aoright:fix/only-valid-args-suggestion-target

Conversation

@aoright

@aoright aoright commented Aug 19, 2026

Copy link
Copy Markdown

Problem

In OnlyValidArgs, when validating positional arguments in the loop for _, v := range args, if an argument v is invalid, the error message generated suggestions via cmd.findSuggestions(args[0]) instead of cmd.findSuggestions(v). In multi-arg invocations where the first argument was valid and subsequent arguments were invalid, suggestions were computed against args[0] rather than the invalid argument v.

Solution

  • Pass v to cmd.findSuggestions(v) in OnlyValidArgs.
  • Add TestOnlyValidArgs_WithValidAndInvalidArgs test case in args_test.go.

…alidArgs

Signed-off-by: aoright <102943475+aoright@users.noreply.github.com>
@CLAassistant

CLAassistant commented Aug 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants