Codebase list golang-github-vbauerster-mpb / 3443b0d
BarEtaAlpha option Vladimir Bauer 9 years ago
1 changed file(s) with 26 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
00 package mpb
1
2 import "github.com/vbauerster/mpb/decor"
13
24 type BarOption func(*state)
35
4 func AppendDecorators(appenders ...DecoratorFunc) BarOption {
6 func AppendDecorators(appenders ...decor.DecoratorFunc) BarOption {
57 return func(bs *state) {
68 bs.appendFuncs = append(bs.appendFuncs, appenders...)
79 }
810 }
911
10 func PrependDecorators(prependers ...DecoratorFunc) BarOption {
12 func PrependDecorators(prependers ...decor.DecoratorFunc) BarOption {
1113 return func(bs *state) {
1214 bs.prependFuncs = append(bs.prependFuncs, prependers...)
1315 }
1416 }
1517
16 func BarTrimLeft(bs *state) {
17 bs.trimLeftSpace = true
18 func BarTrimLeft() BarOption {
19 return func(bs *state) {
20 bs.trimLeftSpace = true
21 }
1822 }
1923
20 func BarTrimRight(bs *state) {
21 bs.trimRightSpace = true
24 func BarTrimRight() BarOption {
25 return func(bs *state) {
26 bs.trimRightSpace = true
27 }
2228 }
2329
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 }
2735 }
2836
2937 func BarID(id int) BarOption {
3038 return func(bs *state) {
3139 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
3249 }
3350 }
3451