Skip to content

fix: allow unknown flags to activate unassigned variadic positionals - #10

Merged
amterp merged 1 commit into
mainfrom
fixx
Oct 5, 2025
Merged

amterp merged 1 commit into
mainfrom
fixx

Conversation

@amterp

@amterp amterp commented Oct 5, 2025

Copy link
Copy Markdown
Owner

Previously, variadic unknown flag collection only worked when the variadic had already consumed at least one value. This meant that commands like mycmd -U (where the first arg is an unknown flag) would error even with a variadic positional argument and WithVariadicUnknownFlags(true).

The fix adds logic to check for unassigned variadic positionals when encountering unknown flags. If found, the variadic is activated and the unknown flag is consumed. This allows variadics to "wake up" on unknown flags, not just positional values.

Previously, variadic unknown flag collection only worked when the
variadic had already consumed at least one value. This meant that
commands like `mycmd -U` (where the first arg is an unknown flag) would
error even with a variadic positional argument and
WithVariadicUnknownFlags(true).

The fix adds logic to check for unassigned variadic positionals when
encountering unknown flags. If found, the variadic is activated and the
unknown flag is consumed. This allows variadics to "wake up" on unknown
flags, not just positional values.
@amterp
amterp merged commit 0e67d29 into main Oct 5, 2025
@amterp
amterp deleted the fixx branch October 5, 2025 04:43
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.

1 participant