fix(autocomplete): omit hidden flags from suggestions - #122
fix(autocomplete): omit hidden flags from suggestions#122sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Keep hidden/internal CLI flags out of shell-completion suggestions.
Problem
The autocomplete code already respects
cli.VisibleFlagwhen resolving an entered flag throughfindFlag, but the flag-name completion path loops over every flag incmd.Flagswithout applying the same visibility check.That means flags deliberately marked hidden can still be surfaced by Bash/Zsh/Fish/PowerShell completion when the user starts typing
-or--.This is separate from the existing hidden-command work: command suggestions already have their own
child.Hiddenhandling, while this PR fixes flag visibility.Fix
Apply the same
cli.VisibleFlag/IsVisible()guard used byfindFlagbefore generating flag-name completions.Visible flags and aliases keep their existing completion behavior. Flags that do not implement
cli.VisibleFlagare also unchanged.Regression coverage
Added a focused synthetic-command regression with one visible and one hidden flag, each with a short alias. The test verifies both long and short visible names remain suggested while both hidden names are omitted.
Validation
The branch is based directly on current upstream
main(a7719136b8ed401b0c51a05553a5e4f720150307) and contains one DCO-signed commit. The production change is 3 lines in handwritteninternal/autocomplete/autocomplete.go, plus focused regression coverage. Full repository test execution is left to CI.Risk
Low. The change only removes completion candidates for flags the CLI already marks as not visible; parsing and command execution are unchanged.