/
cli.go
96 lines (74 loc) · 1.71 KB
/
cli.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package banner
import "time"
type cli struct {
Title string
Version string
Statement string
AnsiColor ansiColor
AnsiBackground ansiBackground
}
// ------------ color group -----------------
func (c cli) DefaultColor() string {
return c.AnsiColor.Default()
}
func (c cli) TextColor() string {
return c.AnsiColor.White()
}
func (c cli) InfoColor() string {
return c.AnsiColor.Cyan()
}
func (c cli) DebugColor() string {
return c.AnsiColor.Blue()
}
func (c cli) WarningColor() string {
return c.AnsiColor.Yellow()
}
func (c cli) SuccessColor() string {
return c.AnsiColor.Green()
}
func (c cli) ImportantColor() string {
return c.AnsiColor.Red()
}
func (c cli) ErrorColor() string {
return c.AnsiColor.BrightRed()
}
// ------------ message group -----------------------
func (c cli) Default(msg string) string {
return c.DefaultColor() + msg
}
func (c cli) Text(msg string) string {
return c.TextColor() + msg
}
func (c cli) Info(msg string) string {
return c.InfoColor() + msg
}
func (c cli) Debug(msg string) string {
return c.DebugColor() + msg
}
func (c cli) Warning(msg string) string {
return c.WarningColor() + msg
}
func (c cli) Success(msg string) string {
return c.SuccessColor() + msg
}
func (c cli) Important(msg string) string {
return c.ImportantColor() + msg
}
func (c cli) Error(msg string) string {
return c.ErrorColor() + msg
}
// ------------ cli group -----------------
func (c cli) BannerColor() string {
switch int(time.Now().Month()) / 3 {
case 1:
return c.AnsiColor.BrightGreen()
case 2:
return c.AnsiColor.BrightCyan()
case 3:
return c.AnsiColor.BrightYellow()
case 0:
return c.AnsiColor.BrightWhite()
default:
return c.AnsiColor.Default()
}
}