Skip to content

Clear stale extra arguments before parsing a new invocation - #177

Merged
inhere merged 1 commit into
gookit:masterfrom
rupayon123:fix/reset-extra-arguments-on-parse-20261030
Oct 31, 2026
Merged

inhere merged 1 commit into
gookit:masterfrom
rupayon123:fix/reset-extra-arguments-on-parse-20261030

Conversation

@rupayon123

Copy link
Copy Markdown
Contributor

Reusing a command can deliver extra arguments from its previous invocation. ParseArgs only replaces its remaining-argument slice when new extras exist, so an invocation with no extras can silently receive the old ones.

Reset that runtime slice at the start of each parse, retaining existing named-argument binding and validation behavior.

Go 1.26.0 / macOS arm64 validation:

  • Five failing reparse cases and one control pass afterward.
  • Four actual Command.Run calls now receive old, empty, new, empty extras, instead of old, old, new, new.
  • Full coverage and race suites each pass 342 leaf tests across three packages, with no skips.
  • Vet, build, formatting, tidy and the current example pass. Staticcheck still reports 11 baseline diagnostics; Revive retains the same 122 warnings.

Other bound flag/argument values and concurrent-command semantics are unchanged. Other supported Go/OS combinations remain unverified locally.

@inhere
inhere merged commit f7531da into gookit:master Oct 31, 2026
7 checks passed
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