BarEtaAlpha option
Vladimir Bauer
9 years ago
| 0 | 0 | package mpb |
| 1 | ||
| 2 | import "github.com/vbauerster/mpb/decor" | |
| 1 | 3 | |
| 2 | 4 | type BarOption func(*state) |
| 3 | 5 | |
| 4 | func AppendDecorators(appenders ...DecoratorFunc) BarOption { | |
| 6 | func AppendDecorators(appenders ...decor.DecoratorFunc) BarOption { | |
| 5 | 7 | return func(bs *state) { |
| 6 | 8 | bs.appendFuncs = append(bs.appendFuncs, appenders...) |
| 7 | 9 | } |
| 8 | 10 | } |
| 9 | 11 | |
| 10 | func PrependDecorators(prependers ...DecoratorFunc) BarOption { | |
| 12 | func PrependDecorators(prependers ...decor.DecoratorFunc) BarOption { | |
| 11 | 13 | return func(bs *state) { |
| 12 | 14 | bs.prependFuncs = append(bs.prependFuncs, prependers...) |
| 13 | 15 | } |
| 14 | 16 | } |
| 15 | 17 | |
| 16 | func BarTrimLeft(bs *state) { | |
| 17 | bs.trimLeftSpace = true | |
| 18 | func BarTrimLeft() BarOption { | |
| 19 | return func(bs *state) { | |
| 20 | bs.trimLeftSpace = true | |
| 21 | } | |
| 18 | 22 | } |
| 19 | 23 | |
| 20 | func BarTrimRight(bs *state) { | |
| 21 | bs.trimRightSpace = true | |
| 24 | func BarTrimRight() BarOption { | |
| 25 | return func(bs *state) { | |
| 26 | bs.trimRightSpace = true | |
| 27 | } | |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | func BarTrim(bs *state) { | |
| 25 | bs.trimLeftSpace = true | |
| 26 | bs.trimRightSpace = true | |
| 30 | func BarTrim() BarOption { | |
| 31 | return func(bs *state) { | |
| 32 | bs.trimLeftSpace = true | |
| 33 | bs.trimRightSpace = true | |
| 34 | } | |
| 27 | 35 | } |
| 28 | 36 | |
| 29 | 37 | func BarID(id int) BarOption { |
| 30 | 38 | return func(bs *state) { |
| 31 | 39 | bs.id = id |
| 40 | } | |
| 41 | } | |
| 42 | ||
| 43 | // BarEtaAlpha option is a way to adjust ETA behavior. | |
| 44 | // You can play with it, if you're not satisfied with default behavior. | |
| 45 | // Default value is 0.25. | |
| 46 | func BarEtaAlpha(a float64) BarOption { | |
| 47 | return func(bs *state) { | |
| 48 | bs.etaAlpha = a | |
| 32 | 49 | } |
| 33 | 50 | } |
| 34 | 51 |