Skip to content

fix: show BoolWithInverseFlag aliases in help text#2321

Open
wucm667 wants to merge 3 commits intourfave:mainfrom
wucm667:fix/bool-inverse-alias-help
Open

fix: show BoolWithInverseFlag aliases in help text#2321
wucm667 wants to merge 3 commits intourfave:mainfrom
wucm667:fix/bool-inverse-alias-help

Conversation

@wucm667
Copy link
Copy Markdown

@wucm667 wucm667 commented May 7, 2026

Aliases defined on BoolWithInverseFlag are functional but were not displayed in usage/help output. The String() method only rendered --[no-]<name> without including any aliases.

Before

--[no-]color	(default: false)

After

--[no-]color, -c	(default: false)
--[no-]color, --colour	(default: false)

Changes

  • flag_bool_with_inverse.go: Updated String() to append aliases with correct prefix (- for single-char, -- for multi-char)
  • flag_bool_with_inverse_test.go: Added 3 new test cases covering short alias, long alias, and multiple aliases

All existing tests pass, no breaking changes.

Fixes #2216

Aliases defined on BoolWithInverseFlag are functional but were not
displayed in usage/help output. The String() method only rendered
--[no-]<name> without including any aliases.

Now aliases are appended after the primary flag name:
  --[no-]color, -c	(default: false)
  --[no-]color, --colour	(default: false)
  --[no-]color, -c, --colour	(default: false)

Adds test cases for short alias, long alias, and multiple aliases.

Fixes urfave#2216

Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
@wucm667 wucm667 requested a review from a team as a code owner May 7, 2026 07:42
wucm667 added 2 commits May 7, 2026 15:49
The String() method now includes aliases in the help text output.
Regenerate the documentation file to reflect this change.

Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
…pport

Sync the v3.x reference godoc file with the generated output.

Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
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.

BoolWithInverseFlag alias not shown in help

1 participant