Codebase list golang-github-vbauerster-mpb / 7f23e10
BaseRefiller Vladimir Bauer 6 years ago
2 changed file(s) with 13 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1616 // Filler interface.
1717 // Bar renders by calling Filler's Fill method. You can literally have
1818 // any bar kind, by implementing this interface and passing it to the
19 // mpb.Add function.
19 // *Progress.Add method.
2020 type Filler interface {
2121 Fill(w io.Writer, width int, stat *decor.Statistics)
2222 }
2626
2727 func (f FillerFunc) Fill(w io.Writer, width int, stat *decor.Statistics) {
2828 f(w, width, stat)
29 }
30
31 // BaseFiller interface.
32 // If you ever need to implement a custom Filler based on mpb.NewBarFiller,
33 // then you may need to implement this one as well, in order to retain
34 // functionality of some `BarOption`s and method like *Bar.SetRefill.
35 type BaseFiller interface {
36 BaseFiller() Filler
2937 }
3038
3139 // Bar represents a progress Bar.
342342 },
343343 }
344344
345 if f, ok := filler.(BaseFiller); ok {
346 bs.baseF = f.BaseFiller()
347 }
348
345349 for _, opt := range options {
346350 if opt != nil {
347351 opt(bs)