@@ -78,6 +78,9 @@ func listCommand(appCtx *AppContext) *cli.Command {
7878 }
7979
8080 rows := client .MapArray (result , "attributes" )
81+ if appCtx .Quiet {
82+ return printRefs (rows )
83+ }
8184 if cols := c .String ("columns" ); cols != "" {
8285 rows = render .FilterColumns (rows , strings .Split (cols , "," ))
8386 }
@@ -115,6 +118,9 @@ func getCommand(appCtx *AppContext) *cli.Command {
115118 return nil
116119 }
117120
121+ if appCtx .Quiet {
122+ return printRef (row )
123+ }
118124 if cols := c .String ("columns" ); cols != "" {
119125 row = render .IncludeColumns (row , strings .Split (cols , "," ))
120126 }
@@ -151,10 +157,14 @@ func createCommand(appCtx *AppContext) *cli.Command {
151157 return err
152158 }
153159
154- if data , ok := result ["attributes" ].(map [string ]interface {}); ok {
155- return appCtx .Renderer .RenderObject (data )
160+ data , _ := result ["attributes" ].(map [string ]interface {})
161+ if data == nil {
162+ data = result
163+ }
164+ if appCtx .Quiet {
165+ return printRef (data )
156166 }
157- return appCtx .Renderer .RenderObject (result )
167+ return appCtx .Renderer .RenderObject (data )
158168 },
159169 }
160170}
@@ -189,10 +199,14 @@ func updateCommand(appCtx *AppContext) *cli.Command {
189199 return err
190200 }
191201
192- if data , ok := result ["attributes" ].(map [string ]interface {}); ok {
193- return appCtx .Renderer .RenderObject (data )
202+ data , _ := result ["attributes" ].(map [string ]interface {})
203+ if data == nil {
204+ data = result
194205 }
195- return appCtx .Renderer .RenderObject (result )
206+ if appCtx .Quiet {
207+ return printRef (data )
208+ }
209+ return appCtx .Renderer .RenderObject (data )
196210 },
197211 }
198212}
@@ -244,6 +258,9 @@ func relatedCommand(appCtx *AppContext) *cli.Command {
244258 }
245259
246260 rows := client .MapArray (result , "attributes" )
261+ if appCtx .Quiet {
262+ return printRefs (rows )
263+ }
247264 if cols := c .String ("columns" ); cols != "" {
248265 rows = render .FilterColumns (rows , strings .Split (cols , "," ))
249266 }
@@ -252,6 +269,24 @@ func relatedCommand(appCtx *AppContext) *cli.Command {
252269 }
253270}
254271
272+ // printRef outputs only the reference_id from a single row.
273+ func printRef (row map [string ]interface {}) error {
274+ if ref , ok := row ["reference_id" ].(string ); ok {
275+ fmt .Println (ref )
276+ }
277+ return nil
278+ }
279+
280+ // printRefs outputs one reference_id per line from a list of rows.
281+ func printRefs (rows []map [string ]interface {}) error {
282+ for _ , row := range rows {
283+ if ref , ok := row ["reference_id" ].(string ); ok {
284+ fmt .Println (ref )
285+ }
286+ }
287+ return nil
288+ }
289+
255290// parseAttributes parses [key=val ...] args or a single JSON string into a map.
256291func parseAttributes (args []string ) (map [string ]interface {}, error ) {
257292 if len (args ) == 0 {
0 commit comments