@@ -69,28 +69,44 @@ func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) er
6969
7070 params := stainless.BuildTargetOutputGetParams {
7171 BuildID : buildID ,
72+ Target : stainless .BuildTargetOutputGetParamsTarget (cmd .Value ("target" ).(string )),
73+ Type : stainless .BuildTargetOutputGetParamsType (cmd .Value ("type" ).(string )),
74+ Output : stainless .BuildTargetOutputGetParamsOutput (cmd .String ("output" )),
7275 }
73- var resBytes []byte
7476 res , err := client .Builds .TargetOutputs .Get (
7577 ctx ,
7678 params ,
7779 option .WithMiddleware (debugMiddleware (cmd .Bool ("debug" ))),
78- option .WithResponseBodyInto (& resBytes ),
7980 )
8081 if err != nil {
8182 return err
8283 }
8384
84- json := gjson .Parse (string ( resBytes ))
85+ json := gjson .Parse (res . RawJSON ( ))
8586 format := cmd .Root ().String ("format" )
8687 transform := cmd .Root ().String ("transform" )
8788 if err := ShowJSON ("builds:target_outputs retrieve" , json , format , transform ); err != nil {
8889 return err
8990 }
9091
91- group := console .Info ("Downloading output" )
9292 if cmd .Bool ("pull" ) {
93- return build .PullOutput (res .Output , res .URL , res .Ref , cmd .String ("branch" ), "" , group )
93+ group := console .Info ("Downloading output" )
94+
95+ // Check workspace config for target output path
96+ targetDir := ""
97+ wc := getWorkspace (ctx )
98+ target := stainless .Target (cmd .Value ("target" ).(string ))
99+ if targetConfig , ok := wc .Targets [target ]; ok && targetConfig .OutputPath != "" {
100+ targetDir = targetConfig .OutputPath
101+ }
102+
103+ return build .PullOutput (
104+ res .Output ,
105+ res .URL ,
106+ res .Ref ,
107+ cmd .String ("branch" ),
108+ targetDir ,
109+ group )
94110 }
95111
96112 return nil
0 commit comments