Skip to content

Fix: propagate MutuallyExclusiveFlags persistent flags to subcommands - #2266

Merged
dearchap merged 1 commit into
urfave:mainfrom
siutsin:MutuallyExclusiveFlags-persistent-flags-are-not-propagated-to-subcommands
Feb 23, 2026
Merged

dearchap merged 1 commit into
urfave:mainfrom
siutsin:MutuallyExclusiveFlags-persistent-flags-are-not-propagated-to-subcommands

Conversation

@siutsin

@siutsin siutsin commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • bug

What this PR does / why we need it:

  • Fixes persistent flag propagation for flags defined in MutuallyExclusiveFlags groups
  • Changed pCmd.Flags to pCmd.allFlags() in the persistent flag inheritance loop in command_parse.go:39, so that flags from MutuallyExclusiveFlags are included when walking the command lineage
  • Added test TestCommand_ExclusiveFlagsPersistentPropagation to verify the fix

Which issue(s) this PR fixes:

Fixes #2265

Special notes for your reviewer:

allFlags() is already used on line 29 of the same function to populate cmd.appliedFlags for the current command. The ancestor loop on line 39 was the only place still using pCmd.Flags directly, which excluded MutuallyExclusiveFlags groups from propagation.

Testing

  • Added TestCommand_ExclusiveFlagsPersistentPropagation which creates a root command with a MutuallyExclusiveFlags group containing persistent string flags, then verifies a subcommand can receive the flag value
  • All existing tests continue to pass

Release Notes

Fixed persistent flags defined in `MutuallyExclusiveFlags` not being propagated to subcommands

@dearchap
dearchap merged commit 7f5c797 into urfave:main Feb 23, 2026
9 checks passed
Maks1mS pushed a commit to stplr-dev/stplr that referenced this pull request Mar 1, 2026
This PR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [github.com/urfave/cli/v3](https://github.com/urfave/cli) | require | minor | `v3.6.2` → `v3.7.0` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/urfave/cli/badge)](https://securityscorecards.dev/viewer/?uri=github.com/urfave/cli) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>urfave/cli (github.com/urfave/cli/v3)</summary>

### [`v3.7.0`](https://github.com/urfave/cli/releases/tag/v3.7.0)

[Compare Source](urfave/cli@v3.6.2...v3.7.0)

#### What's Changed

- Fix: use the correct type name in the tracef message by [@&#8203;icholy](https://github.com/icholy) in [#&#8203;2251](urfave/cli#2251)
- chore(deps): bump mkdocs-git-revision-date-localized-plugin from 1.5.0 to 1.5.1 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2252](urfave/cli#2252)
- Fix:(issue\_2254) Fix incorrect handling of arg after short option token by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2255](urfave/cli#2255)
- feat: ShellComplete for fish by [@&#8203;marcusramberg](https://github.com/marcusramberg) in [#&#8203;2256](urfave/cli#2256)
- Fix: propagate MutuallyExclusiveFlags persistent flags to subcommands by [@&#8203;siutsin](https://github.com/siutsin) in [#&#8203;2266](urfave/cli#2266)
- feat: support dynamic fish completion by [@&#8203;Maks1mS](https://github.com/Maks1mS) in [#&#8203;2270](urfave/cli#2270)
- fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true by [@&#8203;TimSoethout](https://github.com/TimSoethout) in [#&#8203;2269](urfave/cli#2269)

#### New Contributors

- [@&#8203;marcusramberg](https://github.com/marcusramberg) made their first contribution in [#&#8203;2256](urfave/cli#2256)
- [@&#8203;siutsin](https://github.com/siutsin) made their first contribution in [#&#8203;2266](urfave/cli#2266)
- [@&#8203;TimSoethout](https://github.com/TimSoethout) made their first contribution in [#&#8203;2269](urfave/cli#2269)

**Full Changelog**: <urfave/cli@v3.6.2...v3.7.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday ( * 0-4,22-23 * * 1-5 ), Only on Sunday and Saturday ( * * * * 0,6 ) (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNS4yIiwidXBkYXRlZEluVmVyIjoiNDMuMTUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9EZXBlbmRlbmNpZXMiXX0=-->

Reviewed-on: https://altlinux.space/stapler/stplr/pulls/340
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
pat-s pushed a commit to pat-s/backporter that referenced this pull request Nov 11, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [github.com/urfave/cli/v3](https://github.com/urfave/cli) | `v3.6.1` → `v3.9.0` | ![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2furfave%2fcli%2fv3/v3.9.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2furfave%2fcli%2fv3/v3.6.1/v3.9.0?slim=true) |

---

### Release Notes

<details>
<summary>urfave/cli (github.com/urfave/cli/v3)</summary>

### [`v3.9.0`](https://github.com/urfave/cli/releases/tag/v3.9.0)

[Compare Source](urfave/cli@v3.8.0...v3.9.0)

#### What's Changed

- chore(deps): bump codecov/codecov-action from 5 to 6 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2300](urfave/cli#2300)
- chore(deps): bump the python-packages group across 1 directory with 3 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2301](urfave/cli#2301)
- docs: fix typo by [@&#8203;acrobatstick](https://github.com/acrobatstick) in [#&#8203;2299](urfave/cli#2299)
- feat: add descriptions for bash and powershell autocompletion by [@&#8203;gabelluardo](https://github.com/gabelluardo) in [#&#8203;2298](urfave/cli#2298)
- Made command help more consistent by [@&#8203;markshep-wbg](https://github.com/markshep-wbg) in [#&#8203;2287](urfave/cli#2287)
- Fix:(issue\_2285): correct function and variable naming in fish completion script by [@&#8203;TimSoethout](https://github.com/TimSoethout) in [#&#8203;2286](urfave/cli#2286)
- fix(ci): update docs after bash completion update by [@&#8203;gabelluardo](https://github.com/gabelluardo) in [#&#8203;2307](urfave/cli#2307)
- fix: apply SliceFlagSeparator to env var sources by [@&#8203;lawrence3699](https://github.com/lawrence3699) in [#&#8203;2309](urfave/cli#2309)
- fix: don't print empty line to stderr when Exit message is empty by [@&#8203;Yanhu007](https://github.com/Yanhu007) in [#&#8203;2310](urfave/cli#2310)
- flag: prevent BoolWithInverseFlag.String from panicking without a tab by [@&#8203;alliasgher](https://github.com/alliasgher) in [#&#8203;2311](urfave/cli#2311)
- refactor: bash completion script by [@&#8203;gabelluardo](https://github.com/gabelluardo) in [#&#8203;2308](urfave/cli#2308)
- fix: drop shebang from bash completion template by [@&#8203;barry3406](https://github.com/barry3406) in [#&#8203;2317](urfave/cli#2317)
- fix: show flag completions when completing a double-dash prefix by [@&#8203;morozov](https://github.com/morozov) in [#&#8203;2316](urfave/cli#2316)
- fix: parse flags for help subcommand ([#&#8203;2271](urfave/cli#2271)) by [@&#8203;barry3406](https://github.com/barry3406) in [#&#8203;2319](urfave/cli#2319)
- fix: show BoolWithInverseFlag aliases in help text by [@&#8203;wucm667](https://github.com/wucm667) in [#&#8203;2321](urfave/cli#2321)

#### New Contributors

- [@&#8203;gabelluardo](https://github.com/gabelluardo) made their first contribution in [#&#8203;2298](urfave/cli#2298)
- [@&#8203;markshep-wbg](https://github.com/markshep-wbg) made their first contribution in [#&#8203;2287](urfave/cli#2287)
- [@&#8203;lawrence3699](https://github.com/lawrence3699) made their first contribution in [#&#8203;2309](urfave/cli#2309)
- [@&#8203;Yanhu007](https://github.com/Yanhu007) made their first contribution in [#&#8203;2310](urfave/cli#2310)
- [@&#8203;alliasgher](https://github.com/alliasgher) made their first contribution in [#&#8203;2311](urfave/cli#2311)
- [@&#8203;barry3406](https://github.com/barry3406) made their first contribution in [#&#8203;2317](urfave/cli#2317)
- [@&#8203;morozov](https://github.com/morozov) made their first contribution in [#&#8203;2316](urfave/cli#2316)
- [@&#8203;wucm667](https://github.com/wucm667) made their first contribution in [#&#8203;2321](urfave/cli#2321)

**Full Changelog**: <urfave/cli@v3.8.0...v3.9.0>

### [`v3.8.0`](https://github.com/urfave/cli/releases/tag/v3.8.0)

[Compare Source](urfave/cli@v3.7.0...v3.8.0)

#### What's Changed

- chore(deps): bump mkdocs-material from 9.7.1 to 9.7.2 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2267](urfave/cli#2267)
- chore(deps): bump mkdocs-material from 9.7.2 to 9.7.3 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2272](urfave/cli#2272)
- chore(deps): bump mkdocs-material from 9.7.3 to 9.7.4 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2276](urfave/cli#2276)
- Fix: check MutuallyExclusiveFlags across parent command chain by [@&#8203;siutsin](https://github.com/siutsin) in [#&#8203;2274](urfave/cli#2274)
- Modernize source code by [@&#8203;kolyshkin](https://github.com/kolyshkin) in [#&#8203;2289](urfave/cli#2289)
- flag: replace regexp use by [@&#8203;kolyshkin](https://github.com/kolyshkin) in [#&#8203;2288](urfave/cli#2288)
- chore(deps): bump mkdocs-material from 9.7.4 to 9.7.5 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2284](urfave/cli#2284)
- Fix:(issue\_2281) Remove incorrect check for local flag for set by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2290](urfave/cli#2290)
- Fix:(issue\_2275) Make flag action execution consistent by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2295](urfave/cli#2295)
- Fix:(issue\_2293) --flag="" no longer rejected as missing argument by [@&#8203;idelchi](https://github.com/idelchi) in [#&#8203;2297](urfave/cli#2297)
- Fix:(issue\_2292) Empty positional args no longer break parse loop by [@&#8203;idelchi](https://github.com/idelchi) in [#&#8203;2296](urfave/cli#2296)

#### New Contributors

- [@&#8203;idelchi](https://github.com/idelchi) made their first contribution in [#&#8203;2297](urfave/cli#2297)

**Full Changelog**: <urfave/cli@v3.7.0...v3.8.0>

### [`v3.7.0`](https://github.com/urfave/cli/releases/tag/v3.7.0)

[Compare Source](urfave/cli@v3.6.2...v3.7.0)

#### What's Changed

- Fix: use the correct type name in the tracef message by [@&#8203;icholy](https://github.com/icholy) in [#&#8203;2251](urfave/cli#2251)
- chore(deps): bump mkdocs-git-revision-date-localized-plugin from 1.5.0 to 1.5.1 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2252](urfave/cli#2252)
- Fix:(issue\_2254) Fix incorrect handling of arg after short option token by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2255](urfave/cli#2255)
- feat: ShellComplete for fish by [@&#8203;marcusramberg](https://github.com/marcusramberg) in [#&#8203;2256](urfave/cli#2256)
- Fix: propagate MutuallyExclusiveFlags persistent flags to subcommands by [@&#8203;siutsin](https://github.com/siutsin) in [#&#8203;2266](urfave/cli#2266)
- feat: support dynamic fish completion by [@&#8203;Maks1mS](https://github.com/Maks1mS) in [#&#8203;2270](urfave/cli#2270)
- fix(help): show GLOBAL OPTIONS for leaf subcommands when HideHelpCommand is true by [@&#8203;TimSoethout](https://github.com/TimSoethout) in [#&#8203;2269](urfave/cli#2269)

#### New Contributors

- [@&#8203;marcusramberg](https://github.com/marcusramberg) made their first contribution in [#&#8203;2256](urfave/cli#2256)
- [@&#8203;siutsin](https://github.com/siutsin) made their first contribution in [#&#8203;2266](urfave/cli#2266)
- [@&#8203;TimSoethout](https://github.com/TimSoethout) made their first contribution in [#&#8203;2269](urfave/cli#2269)

**Full Changelog**: <urfave/cli@v3.6.2...v3.7.0>

### [`v3.6.2`](https://github.com/urfave/cli/releases/tag/v3.6.2)

[Compare Source](urfave/cli@v3.6.1...v3.6.2)

#### What's Changed

- chore(deps): bump actions/checkout from 5 to 6 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2230](urfave/cli#2230)
- chore(deps): bump mkdocs-material from 9.6.23 to 9.7.0 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2231](urfave/cli#2231)
- Improve test coverage by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2236](urfave/cli#2236)
- Add more tests to improve code coverage by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2237](urfave/cli#2237)
- Fix:(issue\_2238) Dont process flags for completion command by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2239](urfave/cli#2239)
- Fix:(issue\_2228) Fix for default command by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2232](urfave/cli#2232)
- chore(deps): bump mkdocs-material from 9.7.0 to 9.7.1 in the python-packages group by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2242](urfave/cli#2242)
- Docs: correct typo in migration guide by [@&#8203;kzygmans](https://github.com/kzygmans) in [#&#8203;2243](urfave/cli#2243)
- Fix:(issue\_2244) Dont check req flags for help and completion commands by [@&#8203;dearchap](https://github.com/dearchap) in [#&#8203;2245](urfave/cli#2245)
- Only show separator if command has usage text by [@&#8203;mikecluck](https://github.com/mikecluck) in [#&#8203;2247](urfave/cli#2247)

#### New Contributors

- [@&#8203;kzygmans](https://github.com/kzygmans) made their first contribution in [#&#8203;2243](urfave/cli#2243)
- [@&#8203;mikecluck](https://github.com/mikecluck) made their first contribution in [#&#8203;2247](urfave/cli#2247)

**Full Changelog**: <urfave/cli@v3.6.1...v3.6.2>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43OC4yIiwidXBkYXRlZEluVmVyIjoiNDMuMzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: https://codefloe.com/pat-s/backporter/pulls/13
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.

MutuallyExclusiveFlags persistent flags are not propagated to subcommands

2 participants