AppendETA signature change
Vladimir Bauer
9 years ago
| 40 | 40 |
}
|
| 41 | 41 |
|
| 42 | 42 |
func (b *Bar) PrependETA(padding int) *Bar {
|
| 43 | |
layout := "ETA% " + strconv.Itoa(padding) + "s"
|
|
43 |
layout := "ETA%" + strconv.Itoa(padding) + "s"
|
| 44 | 44 |
b.PrependFunc(func(s *Statistics) string {
|
| 45 | 45 |
return fmt.Sprintf(layout, time.Duration(s.Eta().Seconds())*time.Second)
|
| 46 | 46 |
})
|
|
| 48 | 48 |
}
|
| 49 | 49 |
|
| 50 | 50 |
func (b *Bar) AppendETA(padding int) *Bar {
|
| 51 | |
layout := "ETA% " + strconv.Itoa(padding) + "s"
|
|
51 |
layout := "ETA %" + strconv.Itoa(padding) + "s"
|
| 52 | 52 |
b.AppendFunc(func(s *Statistics) string {
|
| 53 | 53 |
return fmt.Sprintf(layout, time.Duration(s.Eta().Seconds())*time.Second)
|
| 54 | 54 |
})
|
| 19 | 19 |
}
|
| 20 | 20 |
|
| 21 | 21 |
p := mpb.New()
|
| 22 | |
bar := p.AddBar(totalItem).AppendETA().PrependFunc(decor)
|
|
22 |
bar := p.AddBar(totalItem).PrependFunc(decor).AppendETA(-6)
|
| 23 | 23 |
|
| 24 | 24 |
blockSize := rand.Intn(maxBlockSize) + 1
|
| 25 | 25 |
// Fallowing will hang, to prevent
|
| 36 | 36 |
|
| 37 | 37 |
p := mpb.New().SetWidth(64)
|
| 38 | 38 |
|
| 39 | |
bar := p.AddBar(int(size)).PrependCounters(mpb.UnitBytes, 20).AppendETA()
|
|
39 |
bar := p.AddBar(int(size)).PrependCounters(mpb.UnitBytes, 20).AppendETA(-6)
|
| 40 | 40 |
|
| 41 | 41 |
// create proxy reader
|
| 42 | 42 |
reader := bar.ProxyReader(resp.Body)
|
| 20 | 20 |
name1 := "Bar#1: "
|
| 21 | 21 |
bar1 := p.AddBar(100).
|
| 22 | 22 |
PrependName(name1, len(name1)).PrependFunc(getDecor()).
|
| 23 | |
AppendETA()
|
|
23 |
AppendETA(-6)
|
| 24 | 24 |
wg.Add(1)
|
| 25 | 25 |
go func() {
|
| 26 | 26 |
defer wg.Done()
|
|
| 34 | 34 |
|
| 35 | 35 |
bar2 := p.AddBar(60).
|
| 36 | 36 |
PrependName("", 0-len(name1)).PrependFunc(getDecor()).
|
| 37 | |
AppendETA()
|
|
37 |
AppendETA(-6)
|
| 38 | 38 |
wg.Add(1)
|
| 39 | 39 |
go func() {
|
| 40 | 40 |
defer wg.Done()
|
|
| 48 | 48 |
|
| 49 | 49 |
bar3 := p.AddBar(80).
|
| 50 | 50 |
PrependName("Bar#3: ", 0).PrependFunc(getDecor()).
|
| 51 | |
AppendETA()
|
|
51 |
AppendETA(-6)
|
| 52 | 52 |
wg.Add(1)
|
| 53 | 53 |
go func() {
|
| 54 | 54 |
defer wg.Done()
|