forked from getfider/fider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.go
74 lines (64 loc) · 1.71 KB
/
colors.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
package log
import (
"fmt"
"strings"
)
var (
colorRed = "\033[31m"
colorGreen = "\033[32m"
colorYellow = "\033[33m"
colorBlue = "\033[34m"
colorMagenta = "\033[36m"
styleBold = "\033[1m"
styleReverse = "\033[7m"
resetAll = "\033[0m"
)
// Color return content with given color
func Color(colorName string, content interface{}) string {
switch strings.ToUpper(colorName) {
case "RED":
return Red(content)
case "GREEN":
return Green(content)
case "YELLOW":
return Yellow(content)
case "BLUE":
return Blue(content)
case "MAGENTA":
return Magenta(content)
case "BOLD":
return Bold(content)
case "REVERSE":
return Reverse(content)
default:
return fmt.Sprintf("%v", content)
}
}
// Red return content with red color
func Red(content interface{}) string {
return fmt.Sprintf("%s%v%s", colorRed, content, resetAll)
}
// Green return content with green color
func Green(content interface{}) string {
return fmt.Sprintf("%s%v%s", colorGreen, content, resetAll)
}
// Yellow return content with yellow color
func Yellow(content interface{}) string {
return fmt.Sprintf("%s%v%s", colorYellow, content, resetAll)
}
// Blue return content with blue color
func Blue(content interface{}) string {
return fmt.Sprintf("%s%v%s", colorBlue, content, resetAll)
}
// Magenta return content with magenta color
func Magenta(content interface{}) string {
return fmt.Sprintf("%s%v%s", colorMagenta, content, resetAll)
}
// Bold return content with bold text
func Bold(content interface{}) string {
return fmt.Sprintf("%s%v%s", styleBold, content, resetAll)
}
// Reverse return content with reverse colors
func Reverse(content interface{}) string {
return fmt.Sprintf("%s%v%s", styleReverse, content, resetAll)
}