fix: allow shell completions to work without a database (#1118)

Add "__complete" to noDbCommands list so that Cobra's internal completion
command can run without requiring a beads database to be present.

Previously, running shell completions (e.g., `bd show <TAB>`) in a directory
without a .beads database would fail with "no beads database found" error.

Now completions return empty results gracefully when no database exists,
allowing basic command completion to work everywhere while issue ID
completion still requires a database.

Added integration test that verifies __complete command works without a database.
This commit is contained in:
Dmitry Verkhoturov
2026-01-16 03:22:55 +00:00
committed by GitHub
parent 5d93aaf722
commit c1a9dda173
2 changed files with 125 additions and 0 deletions

View File

@@ -355,6 +355,8 @@ var rootCmd = &cobra.Command{
// Skip database initialization for commands that don't need a database
noDbCommands := []string{
cmdDaemon,
"__complete", // Cobra's internal completion command (shell completions work without db)
"__completeNoDesc", // Cobra's completion without descriptions (used by fish)
"bash",
"completion",
"doctor",