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
|
|
}
|