@@ -140,6 +140,11 @@ func localPreviewFunc(useHeaders bool) cli.ActionFunc {
140140 return err
141141 }
142142
143+ noAnimation := cliCmd .Bool (flagNoAnimation .Name )
144+ if noAnimation {
145+ return runPlainLocalPreview (ctx , moduleID , triggerMutation .VersionProposeLocalWorkspace )
146+ }
147+
143148 model := newModuleLocalPreviewModel (moduleID , triggerMutation .VersionProposeLocalWorkspace )
144149
145150 go func () {
@@ -187,6 +192,74 @@ func localPreviewFunc(useHeaders bool) cli.ActionFunc {
187192 }
188193}
189194
195+ func runPlainLocalPreview (ctx context.Context , moduleID string , initialRuns []runQuery ) error {
196+ runs := make ([]runQuery , len (initialRuns ))
197+ copy (runs , initialRuns )
198+
199+ printRun := func (run runQuery ) {
200+ fmt .Printf ("%s • %s • %s\n " , run .State , run .Title , authenticated .Client ().URL (
201+ "/module/%s/run/%s" ,
202+ moduleID ,
203+ run .ID ,
204+ ))
205+ }
206+
207+ for _ , run := range runs {
208+ printRun (run )
209+ }
210+
211+ ticker := time .NewTicker (time .Second * 5 )
212+ defer ticker .Stop ()
213+
214+ for range ticker .C {
215+ newRuns := make ([]runQuery , len (runs ))
216+ var g errgroup.Group
217+ for i := range newRuns {
218+ index := i
219+ g .Go (func () error {
220+ var getRun struct {
221+ Module struct {
222+ Run runQuery `graphql:"run(id: $run)"`
223+ } `graphql:"module(id: $module)"`
224+ }
225+
226+ if err := authenticated .Client ().Query (ctx , & getRun , map [string ]interface {}{
227+ "module" : graphql .ID (moduleID ),
228+ "run" : graphql .ID (runs [index ].ID ),
229+ }); err != nil {
230+ return err
231+ }
232+
233+ newRuns [index ] = getRun .Module .Run
234+ return nil
235+ })
236+ }
237+ if err := g .Wait (); err != nil {
238+ return fmt .Errorf ("couldn't get runs: %w" , err )
239+ }
240+
241+ for i , newRun := range newRuns {
242+ if newRun .State != runs [i ].State {
243+ printRun (newRun )
244+ }
245+ }
246+ runs = newRuns
247+
248+ allFinished := true
249+ for _ , run := range runs {
250+ if ! run .Finished {
251+ allFinished = false
252+ break
253+ }
254+ }
255+ if allFinished {
256+ return nil
257+ }
258+ }
259+
260+ return nil
261+ }
262+
190263type checkRunsFinishedMsg struct {}
191264
192265type moduleLocalPreviewModel struct {
0 commit comments