Skip to content

Fix inverse bool flag counting with an external counter - #2432

Open
jakezwang wants to merge 1 commit into
urfave:mainfrom
jakezwang:fix/inverse-bool-external-count
Open

jakezwang wants to merge 1 commit into
urfave:mainfrom
jakezwang:fix/inverse-bool-external-count

Conversation

@jakezwang

Copy link
Copy Markdown

What type of PR is this?

  • bug

What this PR does / why we need it:

With BoolWithInverseFlag.Config.Count configured, Count() stays at zero and OnlyOnce accepts repeated flags because only the external counter is incremented.

  • Track the flag's invocation count independently of the optional external counter.
  • Add Command.Run regressions for positive/inverse names and aliases, duplicate rejection, and a pre-populated external counter.

Which issue(s) this PR fixes:

No existing issue.

Testing

Go 1.27 and 1.26: vet, full race tests, and binary-size checks. Go 1.27: generated docs check, README examples, goimports, API diff check, and golangci-lint 2.13.2 (0 issues). The regression fails against the unchanged implementation.

Release Notes

Fix BoolWithInverseFlag.Count and OnlyOnce when an external count is configured.

@jakezwang
jakezwang requested a review from a team as a code owner September 18, 2026 23:20
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