diff --git a/bar.go b/bar.go index d629e78..6e062b9 100644 --- a/bar.go +++ b/bar.go @@ -203,18 +203,23 @@ b.arbitraryCurrent.Unlock() } -// Increment is a shorthand for b.IncrBy(1). -func (b *Bar) Increment() { - b.IncrBy(1) -} - -// IncrBy increments progress bar by amount of n. -// wdd is optional work duration i.e. time.Since(start), which expected -// to be provided, if any ewma based decorator is used. +// Increment is a shorthand for b.IncrInt64(1). +func (b *Bar) Increment(wdd ...time.Duration) { + b.IncrInt64(1, wdd...) +} + +// IncrBy is a shorthand for b.IncrInt64(int64(n), wdd...). func (b *Bar) IncrBy(n int, wdd ...time.Duration) { + b.IncrInt64(int64(n), wdd...) +} + +// IncrInt64 increments progress bar by amount of n. wdd is an optional +// work duration i.e. time.Since(start), which expected to be passed, +// if any ewma based decorator is used. +func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) { select { case b.operateState <- func(s *bState) { - s.current += int64(n) + s.current += n if s.total > 0 && s.current >= s.total { s.current = s.total s.toComplete = true diff --git a/decor/decorator.go b/decor/decorator.go index ee93ff0..b699d48 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -83,7 +83,7 @@ // If decorator needs to receive increment amount, so this is the right // interface to implement. type AmountReceiver interface { - NextAmount(int, ...time.Duration) + NextAmount(int64, ...time.Duration) } // ShutdownListener interface. diff --git a/decor/eta.go b/decor/eta.go index e62c01f..5941204 100644 --- a/decor/eta.go +++ b/decor/eta.go @@ -98,7 +98,7 @@ return d.FormatMsg(str) } -func (d *movingAverageETA) NextAmount(n int, wdd ...time.Duration) { +func (d *movingAverageETA) NextAmount(n int64, wdd ...time.Duration) { var workDuration time.Duration for _, wd := range wdd { workDuration = wd diff --git a/decor/speed.go b/decor/speed.go index a36bb6d..08314b3 100644 --- a/decor/speed.go +++ b/decor/speed.go @@ -192,7 +192,7 @@ return d.FormatMsg(d.msg) } -func (d *movingAverageSpeed) NextAmount(n int, wdd ...time.Duration) { +func (d *movingAverageSpeed) NextAmount(n int64, wdd ...time.Duration) { var workDuration time.Duration for _, wd := range wdd { workDuration = wd