@@ -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