PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
572 B

package ProgressBar
import (
"github.com/vbauerster/mpb"
"github.com/vbauerster/mpb/decor"
)
var (
P = mpb.New()
)
func InitBar(name string, total int) *mpb.Bar {
var (
bar *mpb.Bar
)
bar = P.AddBar(int64(total),
mpb.PrependDecorators(
decor.Name(name),
decor.Percentage(decor.WCSyncSpace),
),
mpb.AppendDecorators(
// replace ETA decorator with "done" message, OnComplete event
decor.OnComplete(
decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
),
),
)
return bar
}
func CloseBar(bar *mpb.Bar) {
bar.Abort(false)
}