Skip to content

Commit

Permalink
inline tui: show run duration at the end (dagger#5476)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Suraci <alex@dagger.io>
  • Loading branch information
vito committed Jul 18, 2023
1 parent 53e57d5 commit d9249d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Added-20230717-173825.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Added
body: show total duration at the end of a run
time: 2023-07-17T17:38:25.400368661-04:00
custom:
Author: vito
PR: "5476"
15 changes: 14 additions & 1 deletion cmd/dagger/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"os"
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/dagger/dagger/engine"
Expand Down Expand Up @@ -183,14 +184,26 @@ func inlineTUI(

var cbErr error
engineErr = engine.Start(ctx, engineConf, func(ctx context.Context, api *router.Router) error {
before := time.Now()

cbErr = fn(ctx, api)

program.Send(progrock.StatusInfoMsg{
Name: "Duration",
Value: time.Since(before).Truncate(time.Millisecond).String(),
Order: 3,
})

return cbErr
})

if cbErr != nil {
return cbErr
} else if engineErr != nil {
return engineErr
}

return engineErr
return nil
}

func newProgrockWriter(dest string) (progrock.Writer, error) {
Expand Down

0 comments on commit d9249d6

Please sign in to comment.