-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
45 lines (35 loc) · 954 Bytes
/
options.go
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 pbar
import (
"io"
"time"
)
// Option is a func type received by PBar.
// Each one allows configuration of the PBar.
type Option func(*PBar)
func RefreshIntervalMilliseconds(interval int) Option {
return func(c *PBar) { c.refreshInterval = time.Duration(interval) * time.Millisecond }
}
func BarLength(length int) Option {
return func(c *PBar) { c.barLength = length }
}
func BarLeft(left rune) Option {
return func(c *PBar) { c.barLeft = left }
}
func BarRight(right rune) Option {
return func(c *PBar) { c.barRight = right }
}
func BarUncompleted(uncompleted rune) Option {
return func(c *PBar) { c.barUncompleted = uncompleted }
}
func BarCompleted(completed rune) Option {
return func(c *PBar) { c.barCompleted = completed }
}
func BarLabel(label string) Option {
return func(c *PBar) { c.barLabel = label }
}
func OutputWriter(writer io.Writer) Option {
return func(c *PBar) {
c.testing = true
c.output = writer
}
}