red tip for spinTipBar example
Vladimir Bauer
2 years ago
| 0 | 0 | package main |
| 1 | 1 | |
| 2 | 2 | import ( |
| 3 | "fmt" | |
| 3 | 4 | "math/rand" |
| 4 | 5 | "time" |
| 5 | 6 | |
| 14 | 15 | total := 100 |
| 15 | 16 | name := "Single Bar:" |
| 16 | 17 | bar := p.New(int64(total), |
| 17 | mpb.BarStyle().Tip(`-`, `\`, `|`, `/`), | |
| 18 | mpb.BarStyle().Tip(`-`, `\`, `|`, `/`).TipMeta(func(s string) string { | |
| 19 | return fmt.Sprint("\033[31m", s, "\033[0m") // red | |
| 20 | }), | |
| 18 | 21 | mpb.PrependDecorators(decor.Name(name)), |
| 19 | 22 | mpb.AppendDecorators(decor.Percentage()), |
| 20 | 23 | ) |