Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion help.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) {
// Trim to handle both "-short" and "--long" flags.
cur := strings.TrimLeft(lastArg, "-")
for _, flag := range flags {
if bflag, ok := flag.(*BoolFlag); ok && bflag.Hidden {
if vf, ok := flag.(VisibleFlag); ok && !vf.IsVisible() {
continue
}

Expand Down
22 changes: 22 additions & 0 deletions help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,28 @@ func TestDefaultCompleteWithFlags(t *testing.T) {
env: map[string]string{"SHELL": "bash"},
expected: "",
},
{
name: "typical-flag-suggestion-hidden-non-bool",
cmd: &Command{
Flags: []Flag{
&StringFlag{Name: "excellent", Hidden: true},
&StringFlag{Name: "excitement"},
},
parent: &Command{
Name: "cmd",
Flags: []Flag{
&BoolFlag{Name: "happiness"},
&Int64Flag{Name: "everybody-jump-on"},
},
Commands: []*Command{
{Name: "putz"},
},
},
},
argv: []string{"cmd", "--e", completionFlag},
env: map[string]string{"SHELL": "bash"},
expected: "--excitement\n",
},
{
name: "flag-suggestion-double-dash-shows-all-flags",
cmd: &Command{
Expand Down