Skip to content

Commit 89c02ac

Browse files
committed
fix: simplify beans show --json output
Output bean data directly without the envelope wrapper: - Add SuccessSingle() helper for unwrapped single-bean JSON output - Update show command to use direct output - Error responses still use structured format with success/error/code
1 parent c25f0e3 commit 89c02ac

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.beans/beans-5gdc--simplify-beans-show-json-output.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Simplify beans show --json output
3-
status: backlog
3+
status: completed
44
type: bug
55
priority: normal
66
created_at: 2025-12-12T23:53:33Z
7-
updated_at: 2025-12-12T23:53:49Z
7+
updated_at: 2025-12-12T23:57:06Z
88
parent: beans-xnp8
99
---
1010

cmd/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var showCmd = &cobra.Command{
4444

4545
// JSON output
4646
if showJSON {
47-
return output.Success(b, "")
47+
return output.SuccessSingle(b)
4848
}
4949

5050
// Raw markdown output (frontmatter + body)

internal/output/output.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ func SuccessWithWarnings(b *bean.Bean, message string, warnings []string) error
5757
})
5858
}
5959

60+
// SuccessSingle outputs a single bean directly (no wrapper).
61+
// This allows intuitive jq usage: beans show --json <id> | jq '.title'
62+
func SuccessSingle(b *bean.Bean) error {
63+
enc := json.NewEncoder(os.Stdout)
64+
enc.SetIndent("", " ")
65+
return enc.Encode(b)
66+
}
67+
6068
// SuccessMultiple outputs a bean array directly (no wrapper).
6169
// This allows intuitive jq usage: beans list --json | jq '.[]'
6270
func SuccessMultiple(beans []*bean.Bean) error {

0 commit comments

Comments
 (0)