-
Notifications
You must be signed in to change notification settings - Fork 123
/
bar_filler.go
41 lines (33 loc) · 930 Bytes
/
bar_filler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package mpb
import (
"io"
"github.com/vbauerster/mpb/v8/decor"
)
// BarFiller interface.
// Bar (without decorators) renders itself by calling BarFiller's Fill method.
//
// If not set, it defaults to terminal width.
type BarFiller interface {
Fill(w io.Writer, stat decor.Statistics)
}
// BarFillerBuilder interface.
// Default implementations are:
//
// BarStyle()
// SpinnerStyle()
// NopStyle()
type BarFillerBuilder interface {
Build() BarFiller
}
// BarFillerFunc is function type adapter to convert compatible function
// into BarFiller interface.
type BarFillerFunc func(w io.Writer, stat decor.Statistics)
func (f BarFillerFunc) Fill(w io.Writer, stat decor.Statistics) {
f(w, stat)
}
// BarFillerBuilderFunc is function type adapter to convert compatible
// function into BarFillerBuilder interface.
type BarFillerBuilderFunc func() BarFiller
func (f BarFillerBuilderFunc) Build() BarFiller {
return f()
}