-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.go
52 lines (41 loc) · 1.12 KB
/
settings.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
46
47
48
49
50
51
52
package main
import (
"strings"
"github.com/fatih/color"
)
type settingsData struct {
supressedMessages map[string]bool
processColors []color.Attribute
processColorsLength int
}
type settings interface {
ShouldSuppressMessage(message string) bool
GetProcessColor(index int) color.Attribute
}
func getSettings() settings {
supressedMessages := make(map[string]bool)
supressedMessages["Terminate batch job (Y/N)?"] = true
processColors := []color.Attribute{
color.FgGreen,
color.FgYellow,
color.FgBlue,
color.FgMagenta,
color.FgCyan,
color.FgHiGreen,
color.FgHiYellow,
color.FgHiBlue,
color.FgHiMagenta,
color.FgHiCyan}
return &settingsData{
supressedMessages: supressedMessages,
processColors: processColors,
processColorsLength: len(processColors)}
}
func (s *settingsData) ShouldSuppressMessage(message string) bool {
test := strings.TrimRight(strings.TrimRight(strings.TrimRight(message, "\r\n"), "\n"), " ")
_, ok := s.supressedMessages[test]
return ok
}
func (s *settingsData) GetProcessColor(index int) color.Attribute {
return s.processColors[index%s.processColorsLength]
}