Codebase list golang-github-vbauerster-mpb / 41fb0fb
mexican bar example: style with Meta Vladimir Bauer 2 years ago
1 changed file(s) with 17 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
00 package main
11
22 import (
3 "fmt"
34 "math/rand"
45 "time"
56
1415 total := 100
1516 name := "Complex Filler:"
1617 bs := mpb.BarStyle()
17 bs.Lbound("[\u001b[36;1m")
18 bs.Filler("_")
19 bs.Tip("\u001b[0m⛵\u001b[36;1m")
20 bs.Padding("_")
21 bs.Rbound("\u001b[0m]")
18 bs.LboundMeta(func(s string) string {
19 return fmt.Sprint("\033[34m", s, "\033[0m") // blue
20 })
21 bs.Filler("_").FillerMeta(func(s string) string {
22 return fmt.Sprint("\033[36m", s, "\033[0m") // cyan
23 })
24 bs.Tip("⛵").TipMeta(func(s string) string {
25 return fmt.Sprint("\033[31m", s, "\033[0m") // red
26 })
27 bs.TipOnComplete() // leave tip on complete
28 bs.Padding("_").PaddingMeta(func(s string) string {
29 return fmt.Sprint("\033[36m", s, "\033[0m") // cyan
30 })
31 bs.RboundMeta(func(s string) string {
32 return fmt.Sprint("\033[34m", s, "\033[0m") // blue
33 })
2234 bar := p.New(int64(total), bs,
2335 mpb.PrependDecorators(decor.Name(name)),
2436 mpb.AppendDecorators(decor.Percentage()),