Skip to content

test: add shell-completion case for hidden BoolWithInverseFlag - #2408

Merged
dearchap merged 2 commits into
mainfrom
issue_2405
Aug 16, 2026
Merged

test: add shell-completion case for hidden BoolWithInverseFlag#2408
dearchap merged 2 commits into
mainfrom
issue_2405

Conversation

@dearchap

Copy link
Copy Markdown
Contributor

What type of PR is this?

(REQUIRED)

  • cleanup

What this PR does / why we need it:

(REQUIRED)

Follow-up from review of #2388.

PR #2388 changed printFlagSuggestions in help.go to skip flags via the VisibleFlag/IsVisible() interface instead of the previous flag.(*BoolFlag) assertion. The previous check only skipped hidden bool flags, and because the *BoolFlag assertion does not match the *BoolWithInverseFlag concrete type, hidden BoolWithInverseFlags were also leaked into shell completion suggestions.

That leak is now fixed by the interface-based check, but the regression test table in TestDefaultCompleteWithFlags only covered the BoolFlag (hidden-bool) and StringFlag (new in #2388) cases.

This PR adds a BoolWithInverseFlag case to the TestDefaultCompleteWithFlags table — a hidden --excellent BoolWithInverseFlag alongside a visible --excitement one — to lock in the fix for this type too.

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #2405

Special notes for your reviewer:

Verified the new test catches the regression: with the old *BoolFlag-only assertion restored in help.go, the case fails with the hidden --excellent leaking into the suggestions (--excellent\n--excitement\n). With the current interface-based check it passes.

Testing

Ran the focused test batch:

go test -count=1 -run "TestDefaultCompleteWithFlags" -v .

All cases pass, including the new typical-flag-suggestion-hidden-bool-with-inverse. make lint and go vet ./... are clean.

Release Notes

(REQUIRED)

NONE

@dearchap
dearchap requested a review from a team as a code owner August 16, 2026 12:30
@dearchap
dearchap merged commit 5ec7335 into main Aug 16, 2026
12 checks passed
@dearchap
dearchap deleted the issue_2405 branch August 16, 2026 12:33
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.

test: add shell-completion case for hidden BoolWithInverseFlag

1 participant