@@ -172,6 +172,7 @@ var buildsList = cli.Command{
172172 & requestflag.YAMLFlag {
173173 Name : "revision" ,
174174 Usage : "A config commit SHA used for the build" ,
175+ Value : requestflag.Value [any ](map [string ]any {}),
175176 Config : requestflag.RequestConfig {
176177 QueryPath : "revision" ,
177178 },
@@ -217,6 +218,7 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
217218 client := stainless .NewClient (getDefaultRequestOptions (cmd )... )
218219
219220 unusedArgs := cmd .Args ().Slice ()
221+
220222 if len (unusedArgs ) > 0 {
221223 return fmt .Errorf ("Unexpected extra arguments: %v" , unusedArgs )
222224 }
@@ -314,7 +316,7 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
314316 data := gjson .Parse (string (build .RawJSON ()))
315317 format := cmd .Root ().String ("format" )
316318 transform := cmd .Root ().String ("transform" )
317- if err := ShowJSON ("builds create" , data , format , transform ); err != nil {
319+ if err := ShowJSON (os . Stdout , "builds create" , data , format , transform ); err != nil {
318320 return err
319321 }
320322
@@ -400,26 +402,24 @@ func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error {
400402 if err != nil {
401403 return err
402404 }
405+
403406 var res []byte
404407 options = append (options , option .WithResponseBodyInto (& res ))
405- _ , err = client .Builds .Get (
406- ctx ,
407- requestflag .CommandRequestValue [string ](cmd , "build-id" ),
408- options ... ,
409- )
408+ _ , err = client .Builds .Get (ctx , requestflag .CommandRequestValue [string ](cmd , "build-id" ), options ... )
410409 if err != nil {
411410 return err
412411 }
413412
414- json := gjson .Parse ( string ( res ) )
413+ obj := gjson .ParseBytes ( res )
415414 format := cmd .Root ().String ("format" )
416415 transform := cmd .Root ().String ("transform" )
417- return ShowJSON ("builds retrieve" , json , format , transform )
416+ return ShowJSON (os . Stdout , "builds retrieve" , obj , format , transform )
418417}
419418
420419func handleBuildsList (ctx context.Context , cmd * cli.Command ) error {
421420 client := stainless .NewClient (getDefaultRequestOptions (cmd )... )
422421 unusedArgs := cmd .Args ().Slice ()
422+
423423 if len (unusedArgs ) > 0 {
424424 return fmt .Errorf ("Unexpected extra arguments: %v" , unusedArgs )
425425 }
@@ -434,26 +434,37 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
434434 if err != nil {
435435 return err
436436 }
437- var res []byte
438- options = append (options , option .WithResponseBodyInto (& res ))
439- _ , err = client .Builds .List (
440- ctx ,
441- params ,
442- options ... ,
443- )
444- if err != nil {
445- return err
446- }
447437
448- json := gjson .Parse (string (res ))
449438 format := cmd .Root ().String ("format" )
450439 transform := cmd .Root ().String ("transform" )
451- return ShowJSON ("builds list" , json , format , transform )
440+ if format == "raw" {
441+ var res []byte
442+ options = append (options , option .WithResponseBodyInto (& res ))
443+ _ , err = client .Builds .List (ctx , params , options ... )
444+ if err != nil {
445+ return err
446+ }
447+ obj := gjson .ParseBytes (res )
448+ return ShowJSON (os .Stdout , "builds list" , obj , format , transform )
449+ } else {
450+ iter := client .Builds .ListAutoPaging (ctx , params , options ... )
451+ return streamOutput ("builds list" , func (w * os.File ) error {
452+ for iter .Next () {
453+ item := iter .Current ()
454+ obj := gjson .Parse (item .RawJSON ())
455+ if err := ShowJSON (w , "builds list" , obj , format , transform ); err != nil {
456+ return err
457+ }
458+ }
459+ return iter .Err ()
460+ })
461+ }
452462}
453463
454464func handleBuildsCompare (ctx context.Context , cmd * cli.Command ) error {
455465 client := stainless .NewClient (getDefaultRequestOptions (cmd )... )
456466 unusedArgs := cmd .Args ().Slice ()
467+
457468 if len (unusedArgs ) > 0 {
458469 return fmt .Errorf ("Unexpected extra arguments: %v" , unusedArgs )
459470 }
@@ -468,19 +479,16 @@ func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
468479 if err != nil {
469480 return err
470481 }
482+
471483 var res []byte
472484 options = append (options , option .WithResponseBodyInto (& res ))
473- _ , err = client .Builds .Compare (
474- ctx ,
475- params ,
476- options ... ,
477- )
485+ _ , err = client .Builds .Compare (ctx , params , options ... )
478486 if err != nil {
479487 return err
480488 }
481489
482- json := gjson .Parse ( string ( res ) )
490+ obj := gjson .ParseBytes ( res )
483491 format := cmd .Root ().String ("format" )
484492 transform := cmd .Root ().String ("transform" )
485- return ShowJSON ("builds compare" , json , format , transform )
493+ return ShowJSON (os . Stdout , "builds compare" , obj , format , transform )
486494}
0 commit comments