mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Make default color sub. Also use default
as defaults
This commit is contained in:
parent
9fccd721e0
commit
e28bdac0ee
@ -76,13 +76,18 @@ func BuildStars(data []Bar, maxStars int, starChar string) string {
|
||||
label = fmt.Sprint(bar.Percent)
|
||||
}
|
||||
|
||||
labelColor := bar.LabelColor
|
||||
if labelColor == "" {
|
||||
labelColor = "default"
|
||||
}
|
||||
|
||||
//write the line
|
||||
buffer.WriteString(
|
||||
fmt.Sprintf(
|
||||
"%s%s[[%s]%s[white]%s] %s\n",
|
||||
"%s%s[[%s]%s[default]%s] %s\n",
|
||||
bar.Label,
|
||||
strings.Repeat(" ", longestLabel-len(bar.Label)),
|
||||
bar.LabelColor,
|
||||
labelColor,
|
||||
strings.Repeat(starChar, starCount),
|
||||
strings.Repeat(" ", maxStars-starCount),
|
||||
label,
|
||||
|
@ -40,7 +40,7 @@ func TestOutput(t *testing.T) {
|
||||
result := BuildStars(makeData(), 20, "*")
|
||||
|
||||
Equal(t,
|
||||
"Jun 27, 2018[[]****[white] ] 20\nJul 09, 2018[[red]****************[white] ] 80\nJul 09, 2018[[green]****************[white] ] 80\n",
|
||||
"Jun 27, 2018[[default]****[default] ] 20\nJul 09, 2018[[red]****************[default] ] 80\nJul 09, 2018[[green]****************[default] ] 80\n",
|
||||
result,
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user