Skip to content

Commit

Permalink
Add color choosing support
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
  • Loading branch information
ulyssessouza committed Dec 9, 2021
1 parent 539558b commit 4ac2fc5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions util/progress/progressui/colors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package progressui

import (
"os"
"strings"

"github.com/morikuni/aec"
)

var termColorMap = map[string]aec.ANSI{
"": colorRun,
"default": aec.DefaultF,

"black": aec.BlackF,
"red": aec.RedF,
"green": aec.GreenF,
"yellow": aec.YellowF,
"blue": aec.BlueF,
"magenta": aec.MagentaF,
"cyan": aec.CyanF,
"white": aec.WhiteF,

"light-black": aec.LightBlackF,
"light-red": aec.LightRedF,
"light-green": aec.LightGreenF,
"light-yellow": aec.LightYellowF,
"light-blue": aec.LightBlueF,
"light-magenta": aec.LightMagentaF,
"light-cyan": aec.LightCyanF,
"light-white": aec.LightWhiteF,
}

func getTermColor() aec.ANSI {
envColorString := os.Getenv("BUILDKIT_TERM_COLOR")
c, ok := termColorMap[strings.ToLower(envColorString)]
if !ok {
return colorRun
}
return c
}
2 changes: 1 addition & 1 deletion util/progress/progressui/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (disp *display) print(d displayInfo, width, height int, all bool) {

out = align(out, timer, width)
if j.completedTime != nil {
color := colorRun
color := getTermColor()
if j.isCanceled {
color = colorCancel
} else if j.hasError {
Expand Down

0 comments on commit 4ac2fc5

Please sign in to comment.