refactoring: xxxOptOnCond
Vladimir Bauer
7 years ago
| 27 | 27 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 28 | 28 |
bar := p.AddBar(int64(total),
|
| 29 | 29 |
// set BarWidth 40 for bar 1 and 2
|
| 30 | |
mpb.BarOptionOnCondition(mpb.BarWidth(40), func() bool { return i > 0 }),
|
|
30 |
mpb.BarOptOnCond(mpb.BarWidth(40), func() bool { return i > 0 }),
|
| 31 | 31 |
mpb.PrependDecorators(
|
| 32 | 32 |
// simple name decorator
|
| 33 | 33 |
decor.Name(name),
|
| 23 | 23 |
for i := 0; i < numBars; i++ {
|
| 24 | 24 |
name := fmt.Sprintf("Bar#%d:", i)
|
| 25 | 25 |
b := p.AddBar(int64(total), mpb.BarID(i),
|
| 26 | |
mpb.BarOptionOnCondition(mpb.BarRemoveOnComplete(), func() bool { return i == 0 }),
|
|
26 |
mpb.BarOptOnCond(mpb.BarRemoveOnComplete(), func() bool { return i == 0 }),
|
| 27 | 27 |
mpb.PrependDecorators(
|
| 28 | 28 |
decor.Name(name),
|
| 29 | 29 |
decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncSpace),
|
| 148 | 148 |
}
|
| 149 | 149 |
}
|
| 150 | 150 |
|
| 151 | |
// BarOptionOnCondition returns option when condition evaluates to true.
|
| 152 | |
func BarOptionOnCondition(option BarOption, condition func() bool) BarOption {
|
|
151 |
// BarOptOnCond returns option when condition evaluates to true.
|
|
152 |
func BarOptOnCond(option BarOption, condition func() bool) BarOption {
|
| 153 | 153 |
if condition() {
|
| 154 | 154 |
return option
|
| 155 | 155 |
}
|
| 88 | 88 |
}
|
| 89 | 89 |
}
|
| 90 | 90 |
|
| 91 | |
// ContainerOptionOnCondition returns option when condition evaluates to true.
|
| 92 | |
func ContainerOptionOnCondition(option ContainerOption, condition func() bool) ContainerOption {
|
|
91 |
// ContainerOptOnCond returns option when condition evaluates to true.
|
|
92 |
func ContainerOptOnCond(option ContainerOption, condition func() bool) ContainerOption {
|
| 93 | 93 |
if condition() {
|
| 94 | 94 |
return option
|
| 95 | 95 |
}
|