Open thep0y opened 2 years ago
You can register a new pb.Element
pb.RegisterElement("myColor", pb.ElementFunc(func(state *pb.State, args ...string) string {
for _, arg := range args {
return color.New(color.BgHiGreen).Sprint(arg)
}
return ""
}), false)
tmpl := `{{counters . | myColor .}} {{bar . }} {{percent . }} {{ myColor . "one" }}`
bar := pb.ProgressBarTemplate(tmpl)
Some colors are defined in
defaultTemplateFuncs
, but these are only some of the colors in thecolor
package, how to use more colors quickly?