Skip to content

fix: skip grouped positionals satisfied by options#6374

Draft
Agentriel wants to merge 1 commit into
clap-rs:masterfrom
Agentriel:fix/issue-1794-grouped-positionals
Draft

fix: skip grouped positionals satisfied by options#6374
Agentriel wants to merge 1 commit into
clap-rs:masterfrom
Agentriel:fix/issue-1794-grouped-positionals

Conversation

@Agentriel
Copy link
Copy Markdown

Fixes #1794.

This changes positional parsing so a positional argument that belongs to a non-multiple ArgGroup is skipped when another member of that group has already been provided on the command line and there is a later positional that can receive the value.

That lets --option1 value bind value to the next positional instead of first assigning it to the grouped positional and then failing validation with an argument conflict. If there is no later positional, parsing still leaves the value on the grouped positional so existing conflict diagnostics are preserved.

Tested locally:

  • cargo fmt --check
  • cargo test --test builder issue_1794
  • cargo test --test builder groups::
  • cargo test --test builder positionals::
  • cargo test -p clap_builder
  • git diff --check

@Agentriel
Copy link
Copy Markdown
Author

GitHub Actions is currently waiting for first-time contributor workflow approval on this PR.

I ran the focused checks locally:

  • cargo fmt --check
  • cargo test --test builder issue_1794
  • cargo test --test builder groups::
  • cargo test --test builder positionals::
  • cargo test -p clap_builder
  • git diff --check

@epage
Copy link
Copy Markdown
Member

epage commented May 11, 2026

Moving to a draft as our contrib guide asks for maintainer buy-in on a proposed solution before moving onto a PR. See also https://epage.github.io/dev/pr-style/#d-issue

@epage epage marked this pull request as draft May 11, 2026 14:16
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.

Conflicting with a positional should allow users to skip it, passing in another positional instead

2 participants