@@ -27,55 +27,55 @@ func getCompletedTargets(buildRes stainlessv0.BuildObject) []targetInfo {
2727 targets := []targetInfo {}
2828
2929 // Check each target and add it to the list if it's completed or in postgen
30- if buildRes .Targets .JSON .Node .IsPresent () {
30+ if buildRes .Targets .JSON .Node .Valid () {
3131 targets = append (targets , targetInfo {
3232 name : "node" ,
3333 status : buildRes .Targets .Node .Status ,
3434 })
3535 }
36- if buildRes .Targets .JSON .Typescript .IsPresent () {
36+ if buildRes .Targets .JSON .Typescript .Valid () {
3737 targets = append (targets , targetInfo {
3838 name : "typescript" ,
3939 status : buildRes .Targets .Typescript .Status ,
4040 })
4141 }
42- if buildRes .Targets .JSON .Python .IsPresent () {
42+ if buildRes .Targets .JSON .Python .Valid () {
4343 targets = append (targets , targetInfo {
4444 name : "python" ,
4545 status : buildRes .Targets .Python .Status ,
4646 })
4747 }
48- if buildRes .Targets .JSON .Go .IsPresent () {
48+ if buildRes .Targets .JSON .Go .Valid () {
4949 targets = append (targets , targetInfo {
5050 name : "go" ,
5151 status : buildRes .Targets .Go .Status ,
5252 })
5353 }
54- if buildRes .Targets .JSON .Cli .IsPresent () {
54+ if buildRes .Targets .JSON .Cli .Valid () {
5555 targets = append (targets , targetInfo {
5656 name : "cli" ,
5757 status : buildRes .Targets .Cli .Status ,
5858 })
5959 }
60- if buildRes .Targets .JSON .Kotlin .IsPresent () {
60+ if buildRes .Targets .JSON .Kotlin .Valid () {
6161 targets = append (targets , targetInfo {
6262 name : "kotlin" ,
6363 status : buildRes .Targets .Kotlin .Status ,
6464 })
6565 }
66- if buildRes .Targets .JSON .Java .IsPresent () {
66+ if buildRes .Targets .JSON .Java .Valid () {
6767 targets = append (targets , targetInfo {
6868 name : "java" ,
6969 status : buildRes .Targets .Java .Status ,
7070 })
7171 }
72- if buildRes .Targets .JSON .Ruby .IsPresent () {
72+ if buildRes .Targets .JSON .Ruby .Valid () {
7373 targets = append (targets , targetInfo {
7474 name : "ruby" ,
7575 status : buildRes .Targets .Ruby .Status ,
7676 })
7777 }
78- if buildRes .Targets .JSON .Terraform .IsPresent () {
78+ if buildRes .Targets .JSON .Terraform .Valid () {
7979 targets = append (targets , targetInfo {
8080 name : "terraform" ,
8181 status : buildRes .Targets .Terraform .Status ,
@@ -188,6 +188,52 @@ var buildsList = cli.Command{
188188 HideHelpCommand : true ,
189189}
190190
191+ var buildsCompare = cli.Command {
192+ Name : "compare" ,
193+ Usage : "Creates two builds whose outputs can be compared directly" ,
194+ Flags : []cli.Flag {
195+ & cli.StringFlag {
196+ Name : "base.revision" ,
197+ Action : getAPIFlagAction [string ]("body" , "base.revision" ),
198+ },
199+ & cli.StringFlag {
200+ Name : "base.branch" ,
201+ Action : getAPIFlagAction [string ]("body" , "base.branch" ),
202+ },
203+ & cli.StringFlag {
204+ Name : "base.commit_message" ,
205+ Action : getAPIFlagAction [string ]("body" , "base.commit_message" ),
206+ },
207+ & cli.StringFlag {
208+ Name : "head.revision" ,
209+ Action : getAPIFlagAction [string ]("body" , "head.revision" ),
210+ },
211+ & cli.StringFlag {
212+ Name : "head.branch" ,
213+ Action : getAPIFlagAction [string ]("body" , "head.branch" ),
214+ },
215+ & cli.StringFlag {
216+ Name : "head.commit_message" ,
217+ Action : getAPIFlagAction [string ]("body" , "head.commit_message" ),
218+ },
219+ & cli.StringFlag {
220+ Name : "project" ,
221+ Action : getAPIFlagAction [string ]("body" , "project" ),
222+ },
223+ & cli.StringFlag {
224+ Name : "targets" ,
225+ Action : getAPIFlagAction [string ]("body" , "targets.#" ),
226+ },
227+ & cli.StringFlag {
228+ Name : "+target" ,
229+ Action : getAPIFlagAction [string ]("body" , "targets.-1" ),
230+ },
231+ },
232+ Before : initAPICommand ,
233+ Action : handleBuildsCompare ,
234+ HideHelpCommand : true ,
235+ }
236+
191237func handleBuildsCreate (ctx context.Context , cmd * cli.Command ) error {
192238 cc := getAPICommandContext (ctx , cmd )
193239
@@ -450,3 +496,20 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
450496 fmt .Printf ("%s\n " , colorizeJSON (res .RawJSON (), os .Stdout ))
451497 return nil
452498}
499+
500+ func handleBuildsCompare (ctx context.Context , cmd * cli.Command ) error {
501+ cc := getAPICommandContext (ctx , cmd )
502+
503+ res , err := cc .client .Builds .Compare (
504+ context .TODO (),
505+ stainlessv0.BuildCompareParams {},
506+ option .WithMiddleware (cc .AsMiddleware ()),
507+ option .WithRequestBody ("application/json" , cc .body ),
508+ )
509+ if err != nil {
510+ return err
511+ }
512+
513+ fmt .Printf ("%s\n " , colorizeJSON (res .RawJSON (), os .Stdout ))
514+ return nil
515+ }
0 commit comments