Skip to content

Fix shared options after nested positional arguments - #998

Open
sean0407 wants to merge 1 commit into
apple:mainfrom
sean0407:fix/swift-argument-parser-994-optiongroup-after-default-subcommand
Open

sean0407 wants to merge 1 commit into
apple:mainfrom
sean0407:fix/swift-argument-parser-994-optiongroup-after-default-subcommand

Conversation

@sean0407

Copy link
Copy Markdown

Fixes #994.

A flag from a shared @OptionGroup is listed by a nested subcommand's help but was rejected when supplied after that subcommand's positional argument, if the root command had a passthrough defaultSubcommand.

When a child command has parsed values for an option group already decoded by its parent, use the child's parsed value and carry it forward to deeper commands. When the child has no value, keep the parent's decoded value. Passthrough commands continue reusing the parent value.

The regression test models a root shared --debug flag, nested image tag <name> commands, and a passthrough default plugin command.

Checks run in a network-disabled container with Swift 6.2.3 on Linux arm64:

  • swift test (567 tests passed)
  • swift-format lint --strict on the four changed files
  • git diff --check

This branch has not been deployed

No deployments
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.

Shared @OptionGroup flag is rejected after a subcommand when the root has a passthrough defaultSubcommand

1 participant