fix(json): standardize JSON output for errors and empty arrays (bd-au0.7)

- Add FatalErrorRespectJSON helper for JSON-aware error output
- Fix bd comments list returning null instead of [] for empty arrays
- Remove redundant local --json flags from show/update/close commands
  that were shadowing the global persistent --json flag
- Update show command error handlers to use FatalErrorRespectJSON

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-23 23:53:00 -08:00
parent 12010b25e5
commit 422ec718e7
4 changed files with 556 additions and 539 deletions

View File

@@ -35,7 +35,7 @@ Examples:
Run: func(cmd *cobra.Command, args []string) {
issueID := args[0]
var comments []*types.Comment
comments := make([]*types.Comment, 0)
usedDaemon := false
if daemonClient != nil {
resp, err := daemonClient.ListComments(&rpc.CommentListArgs{ID: issueID})
@@ -79,6 +79,11 @@ Examples:
comments = result
}
// Normalize nil to empty slice for consistent JSON output
if comments == nil {
comments = make([]*types.Comment, 0)
}
if jsonOutput {
data, err := json.MarshalIndent(comments, "", " ")
if err != nil {