From 165e70568e27fd0a046394236eedd2fb41e927f4 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 23 Sep 2021 18:51:32 +0200 Subject: [PATCH] Enhance ANSI color for progress ui Signed-off-by: CrazyMax --- util/progress/progressui/display.go | 6 +++--- util/progress/progressui/term.go | 12 ++++++++++++ util/progress/progressui/term_windows.go | 12 ++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 util/progress/progressui/term.go create mode 100644 util/progress/progressui/term_windows.go diff --git a/util/progress/progressui/display.go b/util/progress/progressui/display.go index 2eec875806bf..71055c4058d9 100644 --- a/util/progress/progressui/display.go +++ b/util/progress/progressui/display.go @@ -519,11 +519,11 @@ func (disp *display) print(d displayInfo, width, height int, all bool) { out = align(out, timer, width) if j.completedTime != nil { - color := aec.BlueF + color := colorRun if j.isCanceled { - color = aec.YellowF + color = colorCancel } else if j.hasError { - color = aec.RedF + color = colorError } out = aec.Apply(out, color) } diff --git a/util/progress/progressui/term.go b/util/progress/progressui/term.go new file mode 100644 index 000000000000..08f1b8e4d17a --- /dev/null +++ b/util/progress/progressui/term.go @@ -0,0 +1,12 @@ +//go:build !windows +// +build !windows + +package progressui + +import "github.com/morikuni/aec" + +var ( + colorRun = aec.BlueF + colorCancel = aec.YellowF + colorError = aec.RedF +) diff --git a/util/progress/progressui/term_windows.go b/util/progress/progressui/term_windows.go new file mode 100644 index 000000000000..c8ce914a0765 --- /dev/null +++ b/util/progress/progressui/term_windows.go @@ -0,0 +1,12 @@ +//go:build windows +// +build windows + +package progressui + +import "github.com/morikuni/aec" + +var ( + colorRun = aec.CyanF + colorCancel = aec.YellowF + colorError = aec.RedF +)