aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v5/bar_filler.go
blob: 07148bffbc6b9e2e145aff7c0aa303590dc383ca (plain)
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
package mpb

import (
	"io"

	"github.com/vbauerster/mpb/v5/decor"
)

// BarFiller interface.
// Bar (without decorators) renders itself by calling BarFiller's Fill method.
//
//	`reqWidth` is requested width, which is set via:
//	func WithWidth(width int) ContainerOption
//	func BarWidth(width int) BarOption
//
// Default implementations can be obtained via:
//
//	func NewBarFiller(style string, reverse bool) BarFiller
//	func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller
//
type BarFiller interface {
	Fill(w io.Writer, reqWidth int, stat decor.Statistics)
}

// BarFillerFunc is function type adapter to convert function into BarFiller.
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)
}