Codebase list golang-github-vbauerster-mpb / 8436eca
spinner bar example: condFillerBuilder Vladimir Bauer 2 years ago
1 changed file(s) with 5 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
1919 total, numBars := 101, 3
2020 wg.Add(numBars)
2121
22 condFn := func(cond bool) mpb.BarFiller {
22 condFillerBuilder := func(cond bool) mpb.BarFillerBuilder {
2323 if cond {
2424 s := mpb.SpinnerStyle("∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙")
2525 return s.Meta(func(s string) string {
2626 return fmt.Sprint("\033[31m", s, "\033[0m") // red
27 }).Build()
27 })
2828 }
29 return mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟").Build()
29 return mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")
3030 }
3131
3232 for i := 0; i < numBars; i++ {
3333 name := fmt.Sprintf("Bar#%d:", i)
34 bar := p.MustAdd(int64(total),
35 condFn(i != 0),
34 bar := p.New(int64(total),
35 condFillerBuilder(i != 0),
3636 mpb.PrependDecorators(
3737 // simple name decorator
3838 decor.Name(name),