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
4 changes: 3 additions & 1 deletion internal/autocomplete/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func getAllPossibleCompletions(completionStyle CompletionStyle, root *cli.Comman
completions := make([]ShellCompletion, 0)
if len(args) == 0 {
for _, child := range root.Commands {
completions = builder.createFromCommand("", child, completions)
if !child.Hidden {
completions = builder.createFromCommand("", child, completions)
}
}
return CompletionResult{Completions: completions, Behavior: ShellCompletionBehaviorDefault}
}
Expand Down
13 changes: 13 additions & 0 deletions internal/autocomplete/autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestGetCompletions_EmptyArgs(t *testing.T) {
{Name: "generate", Usage: "Generate SDK"},
{Name: "test", Usage: "Run tests"},
{Name: "build", Usage: "Build project"},
{Name: "internal", Usage: "Internal command", Hidden: true},
},
}

Expand Down Expand Up @@ -240,6 +241,18 @@ func TestBashCompletionScriptDoesNotRegisterPlainCompletion(t *testing.T) {
assert.False(t, strings.Contains(completionScript, "\ncomplete -F __openai_bash_autocomplete openai"))
}

func TestFishCompletionScriptDoesNotWriteDebugLogs(t *testing.T) {
t.Parallel()

completionScript, err := shellCompletions[CompletionStyleFish](&cli.Command{}, "openai")
if !assert.NoError(t, err) {
return
}

assert.Contains(t, completionScript, "2>/dev/null")
assert.NotContains(t, completionScript, "fish-debug")
}

func TestGetCompletions_NonBoolFlagValue(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 1 addition & 2 deletions internal/autocomplete/shellscripts/fish_autocomplete.fish
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function ____APPNAME___fish_autocomplete
set -l cmd $tokens[1]
set -l args $tokens[2..-1]

set -l completions (env COMPLETION_STYLE=fish $cmd __complete -- $args $current 2>>/tmp/fish-debug.log)
set -l completions (env COMPLETION_STYLE=fish $cmd __complete -- $args $current 2>/dev/null)
set -l exit_code $status

# Check for custom file completion patterns
Expand Down Expand Up @@ -48,4 +48,3 @@ function ____APPNAME___fish_autocomplete
end

complete -c __APPNAME__ -f -a '(____APPNAME___fish_autocomplete)'