refactoring: examples
Vladimir Bauer
5 years ago
| 23 | 23 |
decor.AverageETA(decor.ET_STYLE_GO), "done",
|
| 24 | 24 |
),
|
| 25 | 25 |
),
|
| 26 | |
mpb.BarExtender(nlBarFiller(mpb.NewBarFiller("╢▌▌░╟"))),
|
|
26 |
mpb.BarExtender(nlBarFiller(mpb.NewBarFiller(mpb.BarStyle()))),
|
| 27 | 27 |
)
|
| 28 | 28 |
// simulating some work
|
| 29 | 29 |
max := 100 * time.Millisecond
|
| 19 | 19 |
)
|
| 20 | 20 |
|
| 21 | 21 |
bar := p.Add(total,
|
| 22 | |
mpb.NewBarFiller("[=>-|"),
|
|
22 |
mpb.NewBarFiller(mpb.BarStyle().Rbound("|")),
|
| 23 | 23 |
mpb.PrependDecorators(
|
| 24 | 24 |
decor.CountersKibiByte("% .2f / % .2f"),
|
| 25 | 25 |
),
|
| 18 | 18 |
|
| 19 | 19 |
for i := 0; i < numBars; i++ {
|
| 20 | 20 |
name := fmt.Sprintf("Bar#%d:", i)
|
|
21 |
bs := mpb.BarStyle()
|
|
22 |
if i == 1 {
|
|
23 |
// reverse Bar#1
|
|
24 |
bs = bs.Tip("<").Reverse()
|
|
25 |
}
|
| 21 | 26 |
bar := p.Add(int64(total),
|
| 22 | |
// reverse Bar#1
|
| 23 | |
mpb.NewBarFillerPick("", i == 1),
|
|
27 |
mpb.NewBarFiller(bs),
|
| 24 | 28 |
mpb.PrependDecorators(
|
| 25 | 29 |
// simple name decorator
|
| 26 | 30 |
decor.Name(name),
|
| 16 | 16 |
// adding a single bar, which will inherit container's width
|
| 17 | 17 |
bar := p.Add(int64(total),
|
| 18 | 18 |
// progress bar filler with customized style
|
| 19 | |
mpb.NewBarFiller("╢▌▌░╟"),
|
|
19 |
mpb.NewBarFiller(mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")),
|
| 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}),
|
| 25 | 25 |
var bar *mpb.Bar
|
| 26 | 26 |
if i == 0 {
|
| 27 | 27 |
bar = p.Add(int64(total),
|
| 28 | |
mpb.NewBarFiller("╢▌▌░╟"),
|
|
28 |
mpb.NewBarFiller(mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")),
|
| 29 | 29 |
mpb.PrependDecorators(
|
| 30 | 30 |
// simple name decorator
|
| 31 | 31 |
decor.Name(name),
|
|
| 40 | 40 |
)
|
| 41 | 41 |
} else {
|
| 42 | 42 |
bar = p.Add(int64(total),
|
| 43 | |
mpb.NewSpinnerFiller(spinnerStyle, mpb.SpinnerOnMiddle),
|
|
43 |
mpb.NewBarFiller(mpb.SpinnerStyle(spinnerStyle...)),
|
| 44 | 44 |
mpb.PrependDecorators(
|
| 45 | 45 |
// simple name decorator
|
| 46 | 46 |
decor.Name(name),
|
| 19 | 19 |
// adding a single bar, which will inherit container's width
|
| 20 | 20 |
bar := p.Add(int64(total),
|
| 21 | 21 |
// progress bar filler with customized style
|
| 22 | |
mpb.NewBarFiller("╢▌▌░╟"),
|
|
22 |
mpb.NewBarFiller(mpb.BarStyle().Lbound("╢").Filler("▌").Tip("▌").Padding("░").Rbound("╟")),
|
| 23 | 23 |
mpb.PrependDecorators(
|
| 24 | 24 |
// display our name with one space on the right
|
| 25 | 25 |
decor.Name(name, decor.WC{W: len(name) + 1, C: decor.DidentRight}),
|