diff options
Diffstat (limited to '')
-rw-r--r-- | dependencies/pkg/mod/github.com/vbauerster/mpb/v6@v6.0.4/decor/elapsed.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/vbauerster/mpb/v6@v6.0.4/decor/elapsed.go b/dependencies/pkg/mod/github.com/vbauerster/mpb/v6@v6.0.4/decor/elapsed.go new file mode 100644 index 0000000..e389f15 --- /dev/null +++ b/dependencies/pkg/mod/github.com/vbauerster/mpb/v6@v6.0.4/decor/elapsed.go @@ -0,0 +1,35 @@ +package decor + +import ( + "time" +) + +// Elapsed decorator. It's wrapper of NewElapsed. +// +// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS] +// +// `wcc` optional WC config +// +func Elapsed(style TimeStyle, wcc ...WC) Decorator { + return NewElapsed(style, time.Now(), wcc...) +} + +// NewElapsed returns elapsed time decorator. +// +// `style` one of [ET_STYLE_GO|ET_STYLE_HHMMSS|ET_STYLE_HHMM|ET_STYLE_MMSS] +// +// `startTime` start time +// +// `wcc` optional WC config +// +func NewElapsed(style TimeStyle, startTime time.Time, wcc ...WC) Decorator { + var msg string + producer := chooseTimeProducer(style) + fn := func(s Statistics) string { + if !s.Completed { + msg = producer(time.Since(startTime)) + } + return msg + } + return Any(fn, wcc...) +} |