Skip to content

fix(autocomplete): omit hidden flags from suggestions - #122

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/autocomplete-hidden-flags
Open

fix(autocomplete): omit hidden flags from suggestions#122
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/autocomplete-hidden-flags

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Keep hidden/internal CLI flags out of shell-completion suggestions.

Problem

The autocomplete code already respects cli.VisibleFlag when resolving an entered flag through findFlag, but the flag-name completion path loops over every flag in cmd.Flags without 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.Hidden handling, while this PR fixes flag visibility.

Fix

Apply the same cli.VisibleFlag / IsVisible() guard used by findFlag before generating flag-name completions.

Visible flags and aliases keep their existing completion behavior. Flags that do not implement cli.VisibleFlag are 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 handwritten internal/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.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 21:30
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