fix(types): show custom types when daemon is running (#1216)

The `bd types` command only checked `if store != nil` to fetch custom
types. In daemon mode, `store` is nil (daemonClient handles RPC instead),
so custom types were never displayed even when configured.

This caused a mismatch where `bd config get types.custom` showed the
correct values but `bd types` showed none.

Fix by calling ensureDirectMode() at the start of the command, matching
the pattern used by `bd config get`. This falls back from daemon mode
to direct storage access when needed.

Co-authored-by: Perttulands <perttu.landstrom@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Perttu Landström
2026-01-21 00:05:03 +02:00
committed by GitHub
parent f7134954b9
commit 9ed74ca233

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
@@ -53,6 +54,13 @@ Examples:
bd types --json # Output as JSON
`,
Run: func(cmd *cobra.Command, args []string) {
// Ensure direct mode for database access (types command needs to read config).
// In daemon mode, store is nil so custom types would never be fetched.
if err := ensureDirectMode("types command requires direct database access"); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
return
}
// Get custom types from config
var customTypes []string
ctx := context.Background()