diff --git a/bar.go b/bar.go index 41a8d7a..644b1fa 100644 --- a/bar.go +++ b/bar.go @@ -33,6 +33,10 @@ shutdown chan struct{} } +// Filler interface. +// Bar rednders by calling Filler's Fill method. You can literally +// have any bar kind, by implementing this interface and passing it +// to the Add method. type Filler interface { Fill(w io.Writer, width int, s *decor.Statistics) } diff --git a/bar_option.go b/bar_option.go index 7b44600..625f784 100644 --- a/bar_option.go +++ b/bar_option.go @@ -47,25 +47,28 @@ } } -// BarRemoveOnComplete is a flag, if set whole bar line will be removed on complete event. -// If both BarRemoveOnComplete and BarClearOnComplete are set, first bar section gets cleared -// and then whole bar line gets removed completely. +// BarRemoveOnComplete is a flag, if set whole bar line will be removed +// on complete event. If both BarRemoveOnComplete and BarClearOnComplete +// are set, first bar section gets cleared and then whole bar line +// gets removed completely. func BarRemoveOnComplete() BarOption { return func(s *bState) { s.removeOnComplete = true } } -// BarReplaceOnComplete is indicator for delayed bar start, after the `runningBar` is complete. -// To achieve bar replacement effect, `runningBar` should has its `BarRemoveOnComplete` option set. +// BarReplaceOnComplete is indicator for delayed bar start, after the +// `runningBar` is complete. To achieve bar replacement effect, +// `runningBar` should has its `BarRemoveOnComplete` option set. func BarReplaceOnComplete(runningBar *Bar) BarOption { return func(s *bState) { s.runningBar = runningBar } } -// BarClearOnComplete is a flag, if set will clear bar section on complete event. -// If you need to remove a whole bar line, refer to BarRemoveOnComplete. +// BarClearOnComplete is a flag, if set will clear bar section on +// complete event. If you need to remove a whole bar line, refer to +// BarRemoveOnComplete. func BarClearOnComplete() BarOption { return func(s *bState) { s.barClearOnComplete = true @@ -73,16 +76,17 @@ } // BarPriority sets bar's priority. -// Zero is highest priority, i.e. bar will be on top. -// If `BarReplaceOnComplete` option is supplied, this option is ignored. +// Zero is highest priority, i.e. bar will be on top. If +// `BarReplaceOnComplete` option is supplied, this option is ignored. func BarPriority(priority int) BarOption { return func(s *bState) { s.priority = priority } } -// BarNewLineExtend takes user defined efn, which gets called each render cycle. -// Any write to provided writer of efn, will appear on new line of respective bar. +// BarNewLineExtend takes user defined efn, which gets called each +// render cycle. Any write to provided writer of efn, will appear on +// new line of respective bar. func BarNewLineExtend(efn func(io.Writer, *decor.Statistics)) BarOption { return func(s *bState) { s.newLineExtendFn = efn @@ -136,9 +140,9 @@ return MakeFillerTypeSpecificBarOption(chk, cb) } -// MakeFillerTypeSpecificBarOption makes BarOption specific to Filler's actual type. -// If you implement your own Filler, so most probably you'll need this. -// See BarStyle or SpinnerStyle for example. +// MakeFillerTypeSpecificBarOption makes BarOption specific to Filler's +// actual type. If you implement your own Filler, so most probably +// you'll need this. See BarStyle or SpinnerStyle for example. func MakeFillerTypeSpecificBarOption( typeChecker func(Filler) (interface{}, bool), cb func(interface{}), diff --git a/decor/counters.go b/decor/counters.go index e4161dc..7d581ee 100644 --- a/decor/counters.go +++ b/decor/counters.go @@ -141,12 +141,14 @@ return Counters(0, pairFormat, wcc...) } -// CountersKibiByte is a wrapper around Counters with predefined unit UnitKiB (bytes/1024). +// CountersKibiByte is a wrapper around Counters with predefined unit +// UnitKiB (bytes/1024). func CountersKibiByte(pairFormat string, wcc ...WC) Decorator { return Counters(UnitKiB, pairFormat, wcc...) } -// CountersKiloByte is a wrapper around Counters with predefined unit UnitKB (bytes/1000). +// CountersKiloByte is a wrapper around Counters with predefined unit +// UnitKB (bytes/1000). func CountersKiloByte(pairFormat string, wcc ...WC) Decorator { return Counters(UnitKB, pairFormat, wcc...) } diff --git a/decor/decorator.go b/decor/decorator.go index 6aaf6c8..77086a0 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -47,35 +47,37 @@ } // Decorator interface. -// A decorator must implement this interface, in order to be used with mpb library. +// A decorator must implement this interface, in order to be used with +// mpb library. type Decorator interface { Decor(*Statistics) string Syncable } // Syncable interface. -// All decorators implement this interface implicitly. -// Its Syncable method exposes width sync channel, if sync is enabled. +// All decorators implement this interface implicitly. Its Syncable +// method exposes width sync channel, if sync is enabled. type Syncable interface { Syncable() (bool, chan int) } // OnCompleteMessenger interface. -// Decorators implementing this interface suppose to return provided string on complete event. +// Decorators implementing this interface suppose to return provided +// string on complete event. type OnCompleteMessenger interface { OnCompleteMessage(string) } // AmountReceiver interface. -// If decorator needs to receive increment amount, -// so this is the right interface to implement. +// If decorator needs to receive increment amount, so this is the right +// interface to implement. type AmountReceiver interface { NextAmount(int, ...time.Duration) } // ShutdownListener interface. -// If decorator needs to be notified once upon bar shutdown event, -// so this is the right interface to implement. +// If decorator needs to be notified once upon bar shutdown event, so +// this is the right interface to implement. type ShutdownListener interface { Shutdown() } @@ -130,8 +132,8 @@ return (wc.C & DSyncWidth) != 0, wc.wsync } -// OnComplete returns decorator, which wraps provided decorator, with sole -// purpose to display provided message on complete event. +// OnComplete returns decorator, which wraps provided decorator, with +// sole purpose to display provided message on complete event. // // `decorator` Decorator to wrap // diff --git a/decor/moving-average.go b/decor/moving-average.go index f9596a2..bce7755 100644 --- a/decor/moving-average.go +++ b/decor/moving-average.go @@ -6,9 +6,9 @@ "github.com/VividCortex/ewma" ) -// MovingAverage is the interface that computes a moving average over a time- -// series stream of numbers. The average may be over a window or exponentially -// decaying. +// MovingAverage is the interface that computes a moving average over +// a time- series stream of numbers. The average may be over a window +// or exponentially decaying. type MovingAverage interface { Add(float64) Value() float64 @@ -57,7 +57,8 @@ s.count++ } -// NewMedianEwma is ewma based MovingAverage, which gets its values from median MovingAverage. +// NewMedianEwma is ewma based MovingAverage, which gets its values +// from median MovingAverage. func NewMedianEwma(age ...float64) MovingAverage { return &medianEwma{ MovingAverage: ewma.NewMovingAverage(age...), diff --git a/decor/speed.go b/decor/speed.go index 395e5d0..74658ce 100644 --- a/decor/speed.go +++ b/decor/speed.go @@ -137,7 +137,8 @@ return MovingAverageSpeed(unit, unitFormat, ewma.NewMovingAverage(age), wcc...) } -// MovingAverageSpeed decorator relies on MovingAverage implementation to calculate its average. +// MovingAverageSpeed decorator relies on MovingAverage implementation +// to calculate its average. // // `unit` one of [0|UnitKiB|UnitKB] zero for no unit // diff --git a/options.go b/options.go index a0e5bf8..0d7cb78 100644 --- a/options.go +++ b/options.go @@ -9,14 +9,14 @@ "github.com/vbauerster/mpb/cwriter" ) -// ProgressOption is a function option which changes the default behavior of -// progress pool, if passed to mpb.New(...ProgressOption). +// ProgressOption is a function option which changes the default +// behavior of progress pool, if passed to mpb.New(...ProgressOption). type ProgressOption func(*pState) -// WithWaitGroup provides means to have a single joint point. -// If *sync.WaitGroup is provided, you can safely call just p.Wait() -// without calling Wait() on provided *sync.WaitGroup. -// Makes sense when there are more than one bar to render. +// WithWaitGroup provides means to have a single joint point. If +// *sync.WaitGroup is provided, you can safely call just p.Wait() +// without calling Wait() on provided *sync.WaitGroup. Makes sense +// when there are more than one bar to render. func WithWaitGroup(wg *sync.WaitGroup) ProgressOption { return func(s *pState) { s.uwg = wg @@ -60,7 +60,8 @@ } } -// WithShutdownNotifier provided chanel will be closed, after all bars have been rendered. +// WithShutdownNotifier provided chanel will be closed, after all bars +// have been rendered. func WithShutdownNotifier(ch chan struct{}) ProgressOption { return func(s *pState) { s.shutdownNotifier = ch