blob: a5a5d1469fe784170937a4863cd6a1d2f2c238aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package decor
// StaticName returns name decorator.
//
// `name` string to display
//
// `wcc` optional WC config
func StaticName(name string, wcc ...WC) Decorator {
return Name(name, wcc...)
}
// Name returns name decorator.
//
// `name` string to display
//
// `wcc` optional WC config
func Name(name string, wcc ...WC) Decorator {
var wc WC
for _, widthConf := range wcc {
wc = widthConf
}
wc.Init()
d := &nameDecorator{
WC: wc,
msg: name,
}
return d
}
type nameDecorator struct {
WC
msg string
complete *string
}
func (d *nameDecorator) Decor(st *Statistics) string {
if st.Completed && d.complete != nil {
return d.FormatMsg(*d.complete)
}
return d.FormatMsg(d.msg)
}
func (d *nameDecorator) OnCompleteMessage(msg string) {
d.complete = &msg
}
|