Codebase list golang-github-vbauerster-mpb / 280f7e8
barStyle methods don't need pointer receiver Vladimir Bauer 2 years ago
2 changed file(s) with 21 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
7070 // BarStyle constructs default bar style which can be altered via
7171 // BarStyleComposer interface.
7272 func BarStyle() BarStyleComposer {
73 bs := &barStyle{
73 bs := barStyle{
7474 style: defaultBarStyle,
7575 tipFrames: []string{defaultBarStyle[iTip]},
7676 }
8080 return bs
8181 }
8282
83 func (s *barStyle) Lbound(bound string) BarStyleComposer {
83 func (s barStyle) Lbound(bound string) BarStyleComposer {
8484 s.style[iLbound] = bound
8585 return s
8686 }
8787
88 func (s *barStyle) LboundMeta(fn func(string) string) BarStyleComposer {
88 func (s barStyle) LboundMeta(fn func(string) string) BarStyleComposer {
8989 s.metaFuncs[iLbound] = makeMetaFunc(fn)
9090 return s
9191 }
9292
93 func (s *barStyle) Rbound(bound string) BarStyleComposer {
93 func (s barStyle) Rbound(bound string) BarStyleComposer {
9494 s.style[iRbound] = bound
9595 return s
9696 }
9797
98 func (s *barStyle) RboundMeta(fn func(string) string) BarStyleComposer {
98 func (s barStyle) RboundMeta(fn func(string) string) BarStyleComposer {
9999 s.metaFuncs[iRbound] = makeMetaFunc(fn)
100100 return s
101101 }
102102
103 func (s *barStyle) Filler(filler string) BarStyleComposer {
103 func (s barStyle) Filler(filler string) BarStyleComposer {
104104 s.style[iFiller] = filler
105105 return s
106106 }
107107
108 func (s *barStyle) FillerMeta(fn func(string) string) BarStyleComposer {
108 func (s barStyle) FillerMeta(fn func(string) string) BarStyleComposer {
109109 s.metaFuncs[iFiller] = makeMetaFunc(fn)
110110 return s
111111 }
112112
113 func (s *barStyle) Refiller(refiller string) BarStyleComposer {
113 func (s barStyle) Refiller(refiller string) BarStyleComposer {
114114 s.style[iRefiller] = refiller
115115 return s
116116 }
117117
118 func (s *barStyle) RefillerMeta(fn func(string) string) BarStyleComposer {
118 func (s barStyle) RefillerMeta(fn func(string) string) BarStyleComposer {
119119 s.metaFuncs[iRefiller] = makeMetaFunc(fn)
120120 return s
121121 }
122122
123 func (s *barStyle) Padding(padding string) BarStyleComposer {
123 func (s barStyle) Padding(padding string) BarStyleComposer {
124124 s.style[iPadding] = padding
125125 return s
126126 }
127127
128 func (s *barStyle) PaddingMeta(fn func(string) string) BarStyleComposer {
128 func (s barStyle) PaddingMeta(fn func(string) string) BarStyleComposer {
129129 s.metaFuncs[iPadding] = makeMetaFunc(fn)
130130 return s
131131 }
132132
133 func (s *barStyle) Tip(frames ...string) BarStyleComposer {
133 func (s barStyle) Tip(frames ...string) BarStyleComposer {
134134 if len(frames) != 0 {
135135 s.tipFrames = frames
136136 }
137137 return s
138138 }
139139
140 func (s *barStyle) TipMeta(fn func(string) string) BarStyleComposer {
140 func (s barStyle) TipMeta(fn func(string) string) BarStyleComposer {
141141 s.metaFuncs[iTip] = makeMetaFunc(fn)
142142 return s
143143 }
144144
145 func (s *barStyle) TipOnComplete() BarStyleComposer {
145 func (s barStyle) TipOnComplete() BarStyleComposer {
146146 s.tipOnComplete = true
147147 return s
148148 }
149149
150 func (s *barStyle) Reverse() BarStyleComposer {
150 func (s barStyle) Reverse() BarStyleComposer {
151151 s.rev = true
152152 return s
153153 }
154154
155 func (s *barStyle) Build() BarFiller {
155 func (s barStyle) Build() BarFiller {
156156 bf := &bFiller{
157157 meta: s.metaFuncs,
158158 tipOnComplete: s.tipOnComplete,
200200 mpb.WithAutoRefresh(),
201201 )
202202 bs := mpb.BarStyle()
203 bs.Lbound(string(runes[0]))
204 bs.Filler(string(runes[1]))
205 bs.Tip(string(runes[2]))
206 bs.Padding(string(runes[3]))
207 bs.Rbound(string(runes[4]))
203 bs = bs.Lbound(string(runes[0]))
204 bs = bs.Filler(string(runes[1]))
205 bs = bs.Tip(string(runes[2]))
206 bs = bs.Padding(string(runes[3]))
207 bs = bs.Rbound(string(runes[4]))
208208 bar := p.New(int64(total), bs, mpb.BarFillerTrim())
209209
210210 bar.IncrBy(total)