examples update
Vladimir Bauer
5 years ago
| 23 | 23 |
decor.AverageETA(decor.ET_STYLE_GO), "done",
|
| 24 | 24 |
),
|
| 25 | 25 |
),
|
| 26 | |
mpb.BarExtender(nlBarFiller(mpb.NewBarFiller("╢▌▌░╟", false))),
|
|
26 |
mpb.BarExtender(nlBarFiller(mpb.NewBarFiller("╢▌▌░╟"))),
|
| 27 | 27 |
)
|
| 28 | 28 |
// simulating some work
|
| 29 | 29 |
max := 100 * time.Millisecond
|
| 16 | 16 |
p := mpb.New(mpb.WithWidth(64))
|
| 17 | 17 |
|
| 18 | 18 |
var total int64
|
|
19 |
// new bar with 'trigger complete event' disabled, because total is zero
|
| 19 | 20 |
bar := p.AddBar(total,
|
| 20 | 21 |
mpb.PrependDecorators(decor.Counters(decor.UnitKiB, "% .1f / % .1f")),
|
| 21 | 22 |
mpb.AppendDecorators(decor.Percentage()),
|
| 18 | 18 |
mpb.WithRefreshRate(180*time.Millisecond),
|
| 19 | 19 |
)
|
| 20 | 20 |
|
| 21 | |
bar := p.AddBar(total, mpb.BarStyle("[=>-|"),
|
|
21 |
bar := p.Add(total,
|
|
22 |
mpb.NewBarFiller("[=>-|"),
|
| 22 | 23 |
mpb.PrependDecorators(
|
| 23 | 24 |
decor.CountersKibiByte("% .2f / % .2f"),
|
| 24 | 25 |
),
|
| 18 | 18 |
|
| 19 | 19 |
for i := 0; i < numBars; i++ {
|
| 20 | 20 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 21 | |
bar := p.AddBar(int64(total),
|
|
21 |
bar := p.Add(int64(total),
|
| 22 | 22 |
// reverse Bar#1
|
| 23 | |
mpb.BarOptOn(mpb.BarReverse(), func() bool { return i == 1 }),
|
|
23 |
mpb.NewBarFillerRev("", func() bool { return i == 1 }),
|
| 24 | 24 |
mpb.PrependDecorators(
|
| 25 | 25 |
// simple name decorator
|
| 26 | 26 |
decor.Name(name),
|
| 14 | 14 |
total := 100
|
| 15 | 15 |
name := "Single Bar:"
|
| 16 | 16 |
// 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("╢▌▌░╟"),
|
| 20 | 20 |
mpb.PrependDecorators(
|
| 21 | 21 |
// display our name with one space on the right
|
| 22 | 22 |
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
|
| 13 | 13 |
var wg sync.WaitGroup
|
| 14 | 14 |
p := mpb.New(
|
| 15 | 15 |
mpb.WithWaitGroup(&wg),
|
| 16 | |
mpb.WithWidth(13),
|
|
16 |
mpb.WithWidth(14),
|
| 17 | 17 |
)
|
| 18 | 18 |
total, numBars := 101, 3
|
| 19 | 19 |
wg.Add(numBars)
|
|
20 |
|
|
21 |
spinnerStyle := []string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"}
|
| 20 | 22 |
|
| 21 | 23 |
for i := 0; i < numBars; i++ {
|
| 22 | 24 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 23 | 25 |
var bar *mpb.Bar
|
| 24 | 26 |
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("╢▌▌░╟"),
|
| 28 | 29 |
mpb.PrependDecorators(
|
| 29 | 30 |
// simple name decorator
|
| 30 | 31 |
decor.Name(name),
|
|
| 38 | 39 |
),
|
| 39 | 40 |
)
|
| 40 | 41 |
} 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),
|
| 44 | 44 |
mpb.PrependDecorators(
|
| 45 | 45 |
// simple name decorator
|
| 46 | 46 |
decor.Name(name),
|
| 41 | 41 |
}
|
| 42 | 42 |
})
|
| 43 | 43 |
}),
|
| 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)),
|
| 50 | 46 |
)
|
| 51 | 47 |
ew := &errorWrapper{}
|
| 52 | 48 |
time.AfterFunc(2*time.Second, func() {
|