mirror of
https://github.com/docker/compose.git
synced 2026-08-03 22:27:30 +00:00
progress for resource can be restarted after more Working event comes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
d8ee474e09
commit
b3792dd258
9 changed files with 17 additions and 20 deletions
|
|
@ -176,6 +176,10 @@ func (e *Event) stop() {
|
|||
e.spinner.Stop()
|
||||
}
|
||||
|
||||
func (e *Event) hasMore() {
|
||||
e.spinner.Restart()
|
||||
}
|
||||
|
||||
var (
|
||||
spinnerDone = "✔"
|
||||
spinnerWarning = "!"
|
||||
|
|
@ -191,6 +195,6 @@ func (e *Event) Spinner() any {
|
|||
case Error:
|
||||
return ErrorColor(spinnerError)
|
||||
default:
|
||||
return e.spinner.String()
|
||||
return CountColor(e.spinner.String())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,3 +64,7 @@ func (s *spinner) String() string {
|
|||
func (s *spinner) Stop() {
|
||||
s.stop = true
|
||||
}
|
||||
|
||||
func (s *spinner) Restart() {
|
||||
s.stop = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,14 +84,11 @@ func (w *ttyWriter) event(e Event) {
|
|||
last := w.events[e.ID]
|
||||
switch e.Status {
|
||||
case Done, Error, Warning:
|
||||
if last.endTime.IsZero() {
|
||||
if last.Status != e.Status {
|
||||
last.stop()
|
||||
}
|
||||
case Working:
|
||||
if !last.endTime.IsZero() {
|
||||
// already done, don't overwrite
|
||||
return
|
||||
}
|
||||
last.hasMore()
|
||||
}
|
||||
last.Status = e.Status
|
||||
last.Text = e.Text
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func TestLineText(t *testing.T) {
|
|||
lineWidth := len(fmt.Sprintf("%s %s", ev.ID, ev.Text))
|
||||
|
||||
out := tty().lineText(ev, "", 50, lineWidth, false)
|
||||
assert.Equal(t, out, " . id Text Status \x1b[34m0.0s \x1b[0m\n")
|
||||
assert.Equal(t, out, " \x1b[33m.\x1b[0m id Text Status \x1b[34m0.0s \x1b[0m\n")
|
||||
|
||||
ev.Status = Done
|
||||
out = tty().lineText(ev, "", 50, lineWidth, false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue