2022-05-02 09:06:34 +02:00
|
|
|
// Package barpool provides access to the global
|
|
|
|
// pool of progress bars, so they could be rendered
|
|
|
|
// altogether.
|
|
|
|
package barpool
|
|
|
|
|
2022-09-21 10:08:33 +02:00
|
|
|
import "github.com/cheggaaa/pb/v3"
|
2022-05-02 09:06:34 +02:00
|
|
|
|
|
|
|
var pool = pb.NewPool()
|
|
|
|
|
|
|
|
// Add adds bar to the global pool
|
|
|
|
func Add(bar *pb.ProgressBar) { pool.Add(bar) }
|
|
|
|
|
|
|
|
// Start starts the global pool
|
|
|
|
// Must be called after all progress bars were added
|
|
|
|
func Start() error { return pool.Start() }
|
|
|
|
|
|
|
|
// Stop stops the global pool
|
|
|
|
func Stop() { _ = pool.Stop() }
|
|
|
|
|
|
|
|
// AddWithTemplate adds bar with the given template
|
|
|
|
// to the global pool
|
|
|
|
func AddWithTemplate(format string, total int) *pb.ProgressBar {
|
|
|
|
bar := pb.ProgressBarTemplate(format).New(total)
|
|
|
|
Add(bar)
|
|
|
|
return bar
|
|
|
|
}
|