BarFillerBuilder interface
Vladimir Bauer
5 years ago
| 13 | 13 | // |
| 14 | 14 | // Default implementations can be obtained via: |
| 15 | 15 | // |
| 16 | // func NewBarFiller(style string) BarFiller | |
| 17 | // func NewBarFillerRev(style string) BarFiller | |
| 18 | // func NewBarFillerPick(style string, rev bool) BarFiller | |
| 19 | // func NewSpinnerFiller(style []string, alignment SpinnerAlignment) BarFiller | |
| 16 | // func NewBarFiller(BarStyle()) BarFiller | |
| 17 | // func NewBarFiller(SpinnerStyle()) BarFiller | |
| 20 | 18 | // |
| 21 | 19 | type BarFiller interface { |
| 22 | 20 | Fill(w io.Writer, reqWidth int, stat decor.Statistics) |
| 21 | } | |
| 22 | ||
| 23 | // BarFillerBuilder interface. | |
| 24 | type BarFillerBuilder interface { | |
| 25 | Build() BarFiller | |
| 23 | 26 | } |
| 24 | 27 | |
| 25 | 28 | // BarFillerFunc is function type adapter to convert function into BarFiller. |
| 28 | 31 | func (f BarFillerFunc) Fill(w io.Writer, reqWidth int, stat decor.Statistics) { |
| 29 | 32 | f(w, reqWidth, stat) |
| 30 | 33 | } |
| 34 | ||
| 35 | // NewBarFiller constructs a BarFiller from provided BarFillerBuilder. | |
| 36 | func NewBarFiller(b BarFillerBuilder) BarFiller { | |
| 37 | return b.Build() | |
| 38 | } | |