@@ -162,6 +162,10 @@ func createRun(opts *CreateOptions) error {
162162 return err
163163 }
164164
165+ if opts .Follow {
166+ return followLogs (opts , client , job .SessionID )
167+ }
168+
165169 sessionURL , err := fetchJobSessionURL (ctx , client , repo , job , opts .BackOff )
166170 opts .IO .StopProgressIndicator ()
167171
@@ -177,9 +181,6 @@ func createRun(opts *CreateOptions) error {
177181 fmt .Fprintf (opts .IO .Out , "job %s queued. View progress: %s\n " , job .ID , capi .AgentsHomeURL )
178182 }
179183
180- if opts .Follow {
181- return followLogs (opts , client , job .SessionID )
182- }
183184 return nil
184185}
185186
@@ -250,8 +251,13 @@ func fetchJobWithBackoff(ctx context.Context, client capi.CapiClient, repo ghrep
250251}
251252
252253func followLogs (opts * CreateOptions , capiClient capi.CapiClient , sessionID string ) error {
253- ctx := context .Background ()
254+ if err := opts .IO .StartPager (); err == nil {
255+ defer opts .IO .StopPager ()
256+ } else {
257+ fmt .Fprintf (opts .IO .ErrOut , "error starting pager: %v\n " , err )
258+ }
254259
260+ ctx := context .Background ()
255261 renderer := opts .LogRenderer ()
256262
257263 var called bool
@@ -267,6 +273,5 @@ func followLogs(opts *CreateOptions, capiClient capi.CapiClient, sessionID strin
267273 return raw , nil
268274 }
269275
270- fmt .Fprintln (opts .IO .Out , "" )
271276 return renderer .Follow (fetcher , opts .IO .Out , opts .IO )
272277}
0 commit comments