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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user