@@ -63,35 +63,33 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
63
63
var (
64
64
currentStage = "Queued"
65
65
currentStageStartedAt = time .Now ().UTC ()
66
- didLogBetweenStage = false
67
66
68
67
errChan = make (chan error , 1 )
69
68
job codersdk.ProvisionerJob
70
69
jobMutex sync.Mutex
71
70
)
72
71
73
72
printStage := func () {
74
- _ , _ = fmt .Fprintf (writer , DefaultStyles . Prompt . Render ( "⧗" ) + " %s\n " , DefaultStyles . Field . Render ( currentStage ) )
73
+ _ , _ = fmt .Fprintf (writer , "==> ⧗ %s\n " , currentStage )
75
74
}
76
75
77
76
updateStage := func (stage string , startedAt time.Time ) {
78
77
if currentStage != "" {
79
- prefix := ""
80
- if ! didLogBetweenStage {
81
- prefix = "\033 [1A\r "
82
- }
83
- mark := DefaultStyles .Checkmark
78
+ mark := "✔"
84
79
if job .CompletedAt != nil && job .Status != codersdk .ProvisionerJobSucceeded {
85
- mark = DefaultStyles .Crossmark
80
+ mark = "✘"
81
+ }
82
+ dur := startedAt .Sub (currentStageStartedAt ).Milliseconds ()
83
+ if dur < 0 {
84
+ dur = 0
86
85
}
87
- _ , _ = fmt .Fprintf (writer , prefix + mark . String () + DefaultStyles . Placeholder . Render ( " %s [%dms]" ) + " \n " , currentStage , startedAt . Sub ( currentStageStartedAt ). Milliseconds () )
86
+ _ , _ = fmt .Fprintf (writer , "=== %s %s [%dms]\n " , mark , currentStage , dur )
88
87
}
89
88
if stage == "" {
90
89
return
91
90
}
92
91
currentStage = stage
93
92
currentStageStartedAt = startedAt
94
- didLogBetweenStage = false
95
93
printStage ()
96
94
}
97
95
@@ -129,7 +127,7 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
129
127
return
130
128
}
131
129
}
132
- _ , _ = fmt .Fprintf (writer , " \033 [2K \r \n " + DefaultStyles .FocusedPrompt .String ()+ DefaultStyles .Bold .Render ("Gracefully canceling..." )+ "\n \n " )
130
+ _ , _ = fmt .Fprintf (writer , DefaultStyles .FocusedPrompt .String ()+ DefaultStyles .Bold .Render ("Gracefully canceling..." )+ "\n \n " )
133
131
err := opts .Cancel ()
134
132
if err != nil {
135
133
errChan <- xerrors .Errorf ("cancel: %w" , err )
@@ -222,10 +220,7 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
222
220
jobMutex .Unlock ()
223
221
continue
224
222
}
225
- _ , _ = fmt .Fprintf (logOutput , "%s %s\n " , DefaultStyles .Placeholder .Render (" " ), output )
226
- if ! opts .Silent {
227
- didLogBetweenStage = true
228
- }
223
+ _ , _ = fmt .Fprintf (logOutput , "%s\n " , output )
229
224
jobMutex .Unlock ()
230
225
}
231
226
}
0 commit comments