@@ -21,113 +21,145 @@ var (
2121)
2222
2323var showCmd = & cobra.Command {
24- Use : "show <id>" ,
24+ Use : "show <id> [id...] " ,
2525 Short : "Show a bean's contents" ,
26- Long : `Displays the full contents of a bean , including front matter and body.` ,
27- Args : cobra .ExactArgs (1 ),
26+ Long : `Displays the full contents of one or more beans , including front matter and body.` ,
27+ Args : cobra .MinimumNArgs (1 ),
2828 RunE : func (cmd * cobra.Command , args []string ) error {
29- // Query bean via GraphQL resolver
3029 resolver := & graph.Resolver {Core : core }
31- b , err := resolver .Query ().Bean (context .Background (), args [0 ])
32- if err != nil {
33- if showJSON {
34- return output .Error (output .ErrNotFound , err .Error ())
30+
31+ // Collect all beans
32+ var beans []* bean.Bean
33+ for _ , id := range args {
34+ b , err := resolver .Query ().Bean (context .Background (), id )
35+ if err != nil {
36+ if showJSON {
37+ return output .Error (output .ErrNotFound , err .Error ())
38+ }
39+ return fmt .Errorf ("failed to find bean: %w" , err )
3540 }
36- return fmt . Errorf ( "failed to find bean: %w" , err )
37- }
38- if b == nil {
39- if showJSON {
40- return output . Error ( output . ErrNotFound , "bean not found" )
41+ if b == nil {
42+ if showJSON {
43+ return output . Error ( output . ErrNotFound , fmt . Sprintf ( "bean not found: %s" , id ))
44+ }
45+ return fmt . Errorf ( "bean not found: %s" , id )
4146 }
42- return fmt . Errorf ( "bean not found: %s" , args [ 0 ] )
47+ beans = append ( beans , b )
4348 }
4449
4550 // JSON output
4651 if showJSON {
47- return output .SuccessSingle (b )
52+ if len (beans ) == 1 {
53+ return output .SuccessSingle (beans [0 ])
54+ }
55+ return output .SuccessMultiple (beans )
4856 }
4957
5058 // Raw markdown output (frontmatter + body)
5159 if showRaw {
52- content , err := b .Render ()
53- if err != nil {
54- return fmt .Errorf ("failed to render bean: %w" , err )
60+ for i , b := range beans {
61+ if i > 0 {
62+ fmt .Print ("\n ---\n \n " )
63+ }
64+ content , err := b .Render ()
65+ if err != nil {
66+ return fmt .Errorf ("failed to render bean: %w" , err )
67+ }
68+ fmt .Print (string (content ))
5569 }
56- fmt .Print (string (content ))
5770 return nil
5871 }
5972
6073 // Body only (no header, no styling)
6174 if showBodyOnly {
62- fmt .Print (b .Body )
75+ for i , b := range beans {
76+ if i > 0 {
77+ fmt .Print ("\n ---\n \n " )
78+ }
79+ fmt .Print (b .Body )
80+ }
6381 return nil
6482 }
6583
6684 // Default: styled human-friendly output
67- statusCfg := cfg .GetStatus (b .Status )
68- statusColor := "gray"
69- if statusCfg != nil {
70- statusColor = statusCfg .Color
71- }
72- isArchive := cfg .IsArchiveStatus (b .Status )
73-
74- var header strings.Builder
75- header .WriteString (ui .ID .Render (b .ID ))
76- header .WriteString (" " )
77- header .WriteString (ui .RenderStatusWithColor (b .Status , statusColor , isArchive ))
78- if b .Priority != "" {
79- priorityCfg := cfg .GetPriority (b .Priority )
80- priorityColor := "gray"
81- if priorityCfg != nil {
82- priorityColor = priorityCfg .Color
85+ for i , b := range beans {
86+ if i > 0 {
87+ fmt .Println ()
88+ fmt .Println (ui .Muted .Render (strings .Repeat ("═" , 60 )))
89+ fmt .Println ()
8390 }
84- header .WriteString (" " )
85- header .WriteString (ui .RenderPriorityWithColor (b .Priority , priorityColor ))
86- }
87- if len (b .Tags ) > 0 {
88- header .WriteString (" " )
89- header .WriteString (ui .Muted .Render (strings .Join (b .Tags , ", " )))
91+ showStyledBean (b )
9092 }
91- header .WriteString ("\n " )
92- header .WriteString (ui .Title .Render (b .Title ))
93-
94- // Display relationships
95- if b .Parent != "" || len (b .Blocking ) > 0 {
96- header .WriteString ("\n " )
97- header .WriteString (ui .Muted .Render (strings .Repeat ("─" , 50 )))
98- header .WriteString ("\n " )
99- header .WriteString (formatRelationships (b ))
93+
94+ return nil
95+ },
96+ }
97+
98+ // showStyledBean displays a single bean with styled output.
99+ func showStyledBean (b * bean.Bean ) {
100+ statusCfg := cfg .GetStatus (b .Status )
101+ statusColor := "gray"
102+ if statusCfg != nil {
103+ statusColor = statusCfg .Color
104+ }
105+ isArchive := cfg .IsArchiveStatus (b .Status )
106+
107+ var header strings.Builder
108+ header .WriteString (ui .ID .Render (b .ID ))
109+ header .WriteString (" " )
110+ header .WriteString (ui .RenderStatusWithColor (b .Status , statusColor , isArchive ))
111+ if b .Priority != "" {
112+ priorityCfg := cfg .GetPriority (b .Priority )
113+ priorityColor := "gray"
114+ if priorityCfg != nil {
115+ priorityColor = priorityCfg .Color
100116 }
117+ header .WriteString (" " )
118+ header .WriteString (ui .RenderPriorityWithColor (b .Priority , priorityColor ))
119+ }
120+ if len (b .Tags ) > 0 {
121+ header .WriteString (" " )
122+ header .WriteString (ui .Muted .Render (strings .Join (b .Tags , ", " )))
123+ }
124+ header .WriteString ("\n " )
125+ header .WriteString (ui .Title .Render (b .Title ))
101126
127+ // Display relationships
128+ if b .Parent != "" || len (b .Blocking ) > 0 {
102129 header .WriteString ("\n " )
103130 header .WriteString (ui .Muted .Render (strings .Repeat ("─" , 50 )))
131+ header .WriteString ("\n " )
132+ header .WriteString (formatRelationships (b ))
133+ }
104134
105- headerBox := lipgloss .NewStyle ().
106- MarginBottom (1 ).
107- Render (header .String ())
135+ header .WriteString ("\n " )
136+ header .WriteString (ui .Muted .Render (strings .Repeat ("─" , 50 )))
108137
109- fmt .Println (headerBox )
138+ headerBox := lipgloss .NewStyle ().
139+ MarginBottom (1 ).
140+ Render (header .String ())
110141
111- // Render the body with Glamour
112- if b .Body != "" {
113- renderer , err := glamour .NewTermRenderer (
114- glamour .WithAutoStyle (),
115- glamour .WithWordWrap (80 ),
116- )
117- if err != nil {
118- return fmt .Errorf ("failed to create renderer: %w" , err )
119- }
142+ fmt .Println (headerBox )
120143
121- rendered , err := renderer .Render (b .Body )
122- if err != nil {
123- return fmt .Errorf ("failed to render markdown: %w" , err )
124- }
144+ // Render the body with Glamour
145+ if b .Body != "" {
146+ renderer , err := glamour .NewTermRenderer (
147+ glamour .WithAutoStyle (),
148+ glamour .WithWordWrap (80 ),
149+ )
150+ if err != nil {
151+ fmt .Printf ("failed to create renderer: %v\n " , err )
152+ return
153+ }
125154
126- fmt .Print (rendered )
155+ rendered , err := renderer .Render (b .Body )
156+ if err != nil {
157+ fmt .Printf ("failed to render markdown: %v\n " , err )
158+ return
127159 }
128160
129- return nil
130- },
161+ fmt . Print ( rendered )
162+ }
131163}
132164
133165// formatRelationships formats parent and blocks for display.
0 commit comments