Skip to content

Show count flags as optional in usage - #516

Closed
00200200 wants to merge 1 commit into
spf13:masterfrom
00200200:fix-count-flag-usage
Closed

00200200 wants to merge 1 commit into
spf13:masterfrom
00200200:fix-count-flag-usage

Conversation

@00200200

Copy link
Copy Markdown

Summary

Fixes #267.

Count flags set NoOptDefVal, so --foo 2 increments once and leaves 2 as a positional argument, while --foo=2 sets the count. Usage still printed a required-looking count argument, which made the space-separated form look valid.

Print --foo[=count] instead, matching other optional-value flags.

Test plan

  • go test -race ./...
  • TestCountUsageShowsOptionalValue fails on master (--foo count) and passes after the change
  • TestPrintDefaults golden updated for the verbose count flag

Count flags use NoOptDefVal, so --foo 2 leaves 2 as a positional
argument while --foo=2 sets the value. Printing "count" as a required
argument made the space-separated form look valid.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@00200200

00200200 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Closing this PR as I will not be signing the CLA. Thank you!

@00200200 00200200 closed this Oct 5, 2026
@00200200
00200200 deleted the fix-count-flag-usage branch October 5, 2026 12:14
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.

CountVar help message is confusing and/or incorrect

2 participants