Codebase list golang-github-vbauerster-mpb / 552808b
examples update Vladimir Bauer 5 years ago
7 changed file(s) with 18 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
2323 decor.AverageETA(decor.ET_STYLE_GO), "done",
2424 ),
2525 ),
26 mpb.BarExtender(nlBarFiller(mpb.NewBarFiller("╢▌▌░╟", false))),
26 mpb.BarExtender(nlBarFiller(mpb.NewBarFiller("╢▌▌░╟"))),
2727 )
2828 // simulating some work
2929 max := 100 * time.Millisecond
1616 p := mpb.New(mpb.WithWidth(64))
1717
1818 var total int64
19 // new bar with 'trigger complete event' disabled, because total is zero
1920 bar := p.AddBar(total,
2021 mpb.PrependDecorators(decor.Counters(decor.UnitKiB, "% .1f / % .1f")),
2122 mpb.AppendDecorators(decor.Percentage()),
1818 mpb.WithRefreshRate(180*time.Millisecond),
1919 )
2020
21 bar := p.AddBar(total, mpb.BarStyle("[=>-|"),
21 bar := p.Add(total,
22 mpb.NewBarFiller("[=>-|"),
2223 mpb.PrependDecorators(
2324 decor.CountersKibiByte("% .2f / % .2f"),
2425 ),
1818
1919 for i := 0; i < numBars; i++ {
2020 name := fmt.Sprintf("Bar#%d:", i)
21 bar := p.AddBar(int64(total),
21 bar := p.Add(int64(total),
2222 // reverse Bar#1
23 mpb.BarOptOn(mpb.BarReverse(), func() bool { return i == 1 }),
23 mpb.NewBarFillerRev("", func() bool { return i == 1 }),
2424 mpb.PrependDecorators(
2525 // simple name decorator
2626 decor.Name(name),
1414 total := 100
1515 name := "Single Bar:"
1616 // adding a single bar, which will inherit container's width
17 bar := p.AddBar(int64(total),
18 // override DefaultBarStyle, which is "[=>-]<+"
19 mpb.BarStyle("╢▌▌░╟"),
17 bar := p.Add(int64(total),
18 // progress bar filler with customized style
19 mpb.NewBarFiller("╢▌▌░╟"),
2020 mpb.PrependDecorators(
2121 // display our name with one space on the right
2222 decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
1313 var wg sync.WaitGroup
1414 p := mpb.New(
1515 mpb.WithWaitGroup(&wg),
16 mpb.WithWidth(13),
16 mpb.WithWidth(14),
1717 )
1818 total, numBars := 101, 3
1919 wg.Add(numBars)
20
21 spinnerStyle := []string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"}
2022
2123 for i := 0; i < numBars; i++ {
2224 name := fmt.Sprintf("Bar#%d:", i)
2325 var bar *mpb.Bar
2426 if i == 0 {
25 bar = p.AddBar(int64(total),
26 // override mpb.DefaultBarStyle, which is "[=>-]<+"
27 mpb.BarStyle("╢▌▌░╟"),
27 bar = p.Add(int64(total),
28 mpb.NewBarFiller("╢▌▌░╟"),
2829 mpb.PrependDecorators(
2930 // simple name decorator
3031 decor.Name(name),
3839 ),
3940 )
4041 } else {
41 bar = p.AddSpinner(int64(total), mpb.SpinnerOnMiddle,
42 // override mpb.DefaultSpinnerStyle
43 mpb.SpinnerStyle([]string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"}),
42 bar = p.Add(int64(total),
43 mpb.NewSpinnerFiller(spinnerStyle, mpb.SpinnerOnMiddle),
4444 mpb.PrependDecorators(
4545 // simple name decorator
4646 decor.Name(name),
4141 }
4242 })
4343 }),
44 mpb.PrependDecorators(
45 decor.Name("my bar:"),
46 ),
47 mpb.AppendDecorators(
48 newCustomPercentage(nextCh),
49 ),
44 mpb.PrependDecorators(decor.Name("my bar:")),
45 mpb.AppendDecorators(newCustomPercentage(nextCh)),
5046 )
5147 ew := &errorWrapper{}
5248 time.AfterFunc(2*time.Second, func() {