Skip to content

Preserve parent unknown arguments across subcommands - #437

Merged
p-ranav merged 2 commits into
p-ranav:masterfrom
damnbrocrazy-svg:fix/preserve-parent-unknown-args
Oct 2, 2026
Merged

p-ranav merged 2 commits into
p-ranav:masterfrom
damnbrocrazy-svg:fix/preserve-parent-unknown-args

Conversation

@damnbrocrazy-svg

Copy link
Copy Markdown
Contributor

parse_known_args discards unknown arguments collected by a parent parser when it dispatches to a subcommand. With nested subcommands, only the deepest command's unknown arguments survive.

For example, tool --parent-extra P run --child-extra C leaf --leaf-extra L currently returns only --leaf-extra and L. This appends each child's unknown arguments to its parent's collected arguments, preserving all six tokens in order.

Adds coverage for parent-only and child-only unknowns, ordering and duplicates around known values, compound options, nested commands, argc/argv, propagated conversion errors, and unchanged strict-parser rejection.

Validation on upstream dc6bd1e with Windows UCRT GCC 13.2 and C++17:

  • Original reproduction: 2/6 tokens preserved, exit 1.
  • New regression tests on the original header: 2 test cases fail.
  • Patched full suite: 267 passed, 954 assertions, 1 existing skipped test, using the repository warning flags with -Werror.
  • Patched reproduction: 6/6 tokens preserved, exit 0; git diff --check passed.

This is independent of #436 and does not change argument validation or preprocessing. AI-assisted implementation and review; the patch was inspected and the reported tests were run locally.

@p-ranav
p-ranav merged commit 4dbc0ff into p-ranav:master Oct 2, 2026
6 of 8 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