disable triggerComplete if initial total <= 0
Vladimir Bauer
5 years ago
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Add creates a bar which renders itself by provided filler. |
| 108 | // Set total to 0, if you plan to update it later. | |
| 108 | // If `total <= 0` trigger complete event is disabled until reset with *bar.SetTotal(int64, bool). | |
| 109 | 109 | // Panics if *Progress instance is done, i.e. called after *Progress.Wait(). |
| 110 | 110 | func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar { |
| 111 | 111 | if filler == nil { |
| 348 | 348 | debugOut: s.debugOut, |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | if total > 0 { | |
| 352 | bs.triggerComplete = true | |
| 353 | } | |
| 354 | ||
| 351 | 355 | for _, opt := range options { |
| 352 | 356 | if opt != nil { |
| 353 | 357 | opt(bs) |