From 1039a69186066a9e85dbc3585076926f75e31c15 Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 10 Jan 2026 16:31:16 -0800 Subject: [PATCH] fix(daemon): silence deprecation warnings in --json mode Follow-up fixes to PR #1006: - Silence deprecation warnings when --json flag is set (agent ergonomics) - Remove unused outputStatusJSON() function - Remove unused encoding/json import from daemon_status.go Agents parsing JSON output dont need deprecation warnings cluttering stderr. The subcommand syntax (bd daemon start) remains the documented path forward. See bd-ntl3b for deduplication work, bd-kpa7c for type consolidation. Co-Authored-By: Claude Opus 4.5 --- cmd/bd/daemon.go | 32 +++++++++++++++++--------------- cmd/bd/daemon_status.go | 7 ------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/cmd/bd/daemon.go b/cmd/bd/daemon.go index 6cc466f2..26425186 100644 --- a/cmd/bd/daemon.go +++ b/cmd/bd/daemon.go @@ -67,21 +67,23 @@ Run 'bd daemon --help' to see all subcommands.`, return } - // Show deprecation warnings for flag-based actions - if start { - fmt.Fprintf(os.Stderr, "Warning: --start is deprecated, use 'bd daemon start' instead\n") - } - if stop { - fmt.Fprintf(os.Stderr, "Warning: --stop is deprecated, use 'bd daemon stop' instead\n") - } - if stopAll { - fmt.Fprintf(os.Stderr, "Warning: --stop-all is deprecated, use 'bd daemon killall' instead\n") - } - if status { - fmt.Fprintf(os.Stderr, "Warning: --status is deprecated, use 'bd daemon status' instead\n") - } - if health { - fmt.Fprintf(os.Stderr, "Warning: --health is deprecated, use 'bd daemon status --all' instead\n") + // Show deprecation warnings for flag-based actions (skip in JSON mode for agent ergonomics) + if !jsonOutput { + if start { + fmt.Fprintf(os.Stderr, "Warning: --start is deprecated, use 'bd daemon start' instead\n") + } + if stop { + fmt.Fprintf(os.Stderr, "Warning: --stop is deprecated, use 'bd daemon stop' instead\n") + } + if stopAll { + fmt.Fprintf(os.Stderr, "Warning: --stop-all is deprecated, use 'bd daemon killall' instead\n") + } + if status { + fmt.Fprintf(os.Stderr, "Warning: --status is deprecated, use 'bd daemon status' instead\n") + } + if health { + fmt.Fprintf(os.Stderr, "Warning: --health is deprecated, use 'bd daemon status --all' instead\n") + } } // If auto-commit/auto-push flags weren't explicitly provided, read from config diff --git a/cmd/bd/daemon_status.go b/cmd/bd/daemon_status.go index 9cabcaf4..e78819af 100644 --- a/cmd/bd/daemon_status.go +++ b/cmd/bd/daemon_status.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "fmt" "os" "path/filepath" @@ -443,9 +442,3 @@ func showAllDaemonsStatus(cmd *cobra.Command) { os.Exit(1) } } - -// outputStatusJSON outputs the status as JSON (helper to avoid duplicating json.Marshal) -func outputStatusJSON(v interface{}) { - data, _ := json.MarshalIndent(v, "", " ") - fmt.Println(string(data)) -}