aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7/bar_filler.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/bar_filler.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar_filler.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar_filler.go b/vendor/github.com/vbauerster/mpb/v7/bar_filler.go
index a69087c47..81177fc2e 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar_filler.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar_filler.go
@@ -9,31 +9,42 @@ import (
// BarFiller interface.
// Bar (without decorators) renders itself by calling BarFiller's Fill method.
//
-// reqWidth is requested width, set by `func WithWidth(int) ContainerOption`.
+// reqWidth is requested width set by `func WithWidth(int) ContainerOption`.
// If not set, it defaults to terminal width.
//
-// Default implementations can be obtained via:
-//
-// func NewBarFiller(BarStyle()) BarFiller
-// func NewBarFiller(SpinnerStyle()) BarFiller
-//
type BarFiller interface {
Fill(w io.Writer, reqWidth int, stat decor.Statistics)
}
// BarFillerBuilder interface.
+// Default implementations are:
+//
+// BarStyle()
+// SpinnerStyle()
+// NopStyle()
+//
type BarFillerBuilder interface {
Build() BarFiller
}
-// BarFillerFunc is function type adapter to convert function into BarFiller.
+// BarFillerFunc is function type adapter to convert compatible function
+// into BarFiller interface.
type BarFillerFunc func(w io.Writer, reqWidth int, stat decor.Statistics)
func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) {
f(w, reqWidth, stat)
}
+// BarFillerBuilderFunc is function type adapter to convert compatible
+// function into BarFillerBuilder interface.
+type BarFillerBuilderFunc func() BarFiller
+
+func (f BarFillerBuilderFunc) Build() BarFiller {
+ return f()
+}
+
// NewBarFiller constructs a BarFiller from provided BarFillerBuilder.
+// Deprecated. Prefer using `*Progress.New(...)` directly.
func NewBarFiller(b BarFillerBuilder) BarFiller {
return b.Build()
}