single BarExtender option
Vladimir Bauer
3 years ago
| 120 | 120 | |
| 121 | 121 | // BarExtender extends bar with arbitrary lines. Provided BarFiller will be |
| 122 | 122 | // called at each render/flush cycle. Any lines written to the underlying |
| 123 | // io.Writer will be printed after the bar itself. | |
| 124 | func BarExtender(filler BarFiller) BarOption { | |
| 125 | return barExtender(filler, false) | |
| 126 | } | |
| 127 | ||
| 128 | // BarExtenderRev extends bar with arbitrary lines in reverse order. Provided | |
| 129 | // BarFiller will be called at each render/flush cycle. Any lines written | |
| 130 | // to the underlying io.Writer will be printed before the bar itself. | |
| 131 | func BarExtenderRev(filler BarFiller) BarOption { | |
| 132 | return barExtender(filler, true) | |
| 133 | } | |
| 134 | ||
| 135 | func barExtender(filler BarFiller, rev bool) BarOption { | |
| 123 | // io.Writer will extend the bar either in above (rev = true) or below | |
| 124 | // (rev = false) direction. | |
| 125 | func BarExtender(filler BarFiller, rev bool) BarOption { | |
| 136 | 126 | if filler == nil { |
| 137 | 127 | return nil |
| 138 | 128 | } |