From 403e70b2c8fea4dc86be99be49bf829f73694888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Kj=C3=B6lhede?= Date: Sat, 24 Jan 2026 15:32:26 +0100 Subject: [PATCH] Fix shell completions by recognizing Cobra's internal commands The maybeDefaultToSpeak() function was intercepting __complete and __completeNoDesc commands that Cobra uses internally for shell completions. This caused completions to fail silently. Add these hidden commands to isCobraBuiltin() so they pass through to Cobra's completion handler. Co-Authored-By: Claude Opus 4.5 --- cmd/root.go | 3 ++- cmd/root_test.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 4915e2b..44dc095 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -72,7 +72,8 @@ func maybeDefaultToSpeak() { func isCobraBuiltin(name string) bool { name = strings.ToLower(name) - return name == "help" || name == "completion" + return name == "help" || name == "completion" || + name == "__complete" || name == "__completenodesc" } func isKnownSubcommand(name string) bool { diff --git a/cmd/root_test.go b/cmd/root_test.go index 2ad30c8..8536da1 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -43,6 +43,8 @@ func TestMaybeDefaultToSpeak_Builtins(t *testing.T) { cases := [][]string{ {"sag", "help"}, {"sag", "completion"}, + {"sag", "__complete"}, + {"sag", "__completeNoDesc"}, } for _, args := range cases { t.Run(args[1], func(t *testing.T) {