Merge pull request #563 from ijc/progressui-custom-operation
progressui: allow caller to customise "Building" stringdocker-18.09
commit
785436a312
|
@ -228,7 +228,7 @@ func build(clicontext *cli.Context) error {
|
|||
}
|
||||
}
|
||||
// not using shared context to not disrupt display but let is finish reporting errors
|
||||
return progressui.DisplaySolveStatus(context.TODO(), c, os.Stdout, displayCh)
|
||||
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, displayCh)
|
||||
})
|
||||
|
||||
return eg.Wait()
|
||||
|
|
|
@ -92,7 +92,7 @@ func action(clicontext *cli.Context) error {
|
|||
c = cn
|
||||
}
|
||||
// not using shared context to not disrupt display but let is finish reporting errors
|
||||
return progressui.DisplaySolveStatus(context.TODO(), c, os.Stdout, ch)
|
||||
return progressui.DisplaySolveStatus(context.TODO(), "", c, os.Stdout, ch)
|
||||
})
|
||||
eg.Go(func() error {
|
||||
if err := loadDockerTar(pipeR); err != nil {
|
||||
|
|
|
@ -16,13 +16,17 @@ import (
|
|||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
func DisplaySolveStatus(ctx context.Context, c console.Console, w io.Writer, ch chan *client.SolveStatus) error {
|
||||
func DisplaySolveStatus(ctx context.Context, phase string, c console.Console, w io.Writer, ch chan *client.SolveStatus) error {
|
||||
|
||||
modeConsole := c != nil
|
||||
|
||||
disp := &display{c: c}
|
||||
disp := &display{c: c, phase: phase}
|
||||
printer := &textMux{w: w}
|
||||
|
||||
if disp.phase == "" {
|
||||
disp.phase = "Building"
|
||||
}
|
||||
|
||||
t := newTrace(w)
|
||||
|
||||
var done bool
|
||||
|
@ -323,6 +327,7 @@ func addTime(tm *time.Time, d time.Duration) *time.Time {
|
|||
|
||||
type display struct {
|
||||
c console.Console
|
||||
phase string
|
||||
lineCount int
|
||||
repeated bool
|
||||
}
|
||||
|
@ -359,7 +364,7 @@ func (disp *display) print(d displayInfo, all bool) {
|
|||
fmt.Fprint(disp.c, aec.Hide)
|
||||
defer fmt.Fprint(disp.c, aec.Show)
|
||||
|
||||
out := fmt.Sprintf("[+] Building %.1fs (%d/%d) %s", time.Since(d.startTime).Seconds(), d.countCompleted, d.countTotal, statusStr)
|
||||
out := fmt.Sprintf("[+] %s %.1fs (%d/%d) %s", disp.phase, time.Since(d.startTime).Seconds(), d.countCompleted, d.countTotal, statusStr)
|
||||
out = align(out, "", width)
|
||||
fmt.Fprintln(disp.c, out)
|
||||
lineCount := 0
|
||||
|
|
Loading…
Reference in New Issue