-
Notifications
You must be signed in to change notification settings - Fork 4
/
chalk.v
67 lines (61 loc) · 1.38 KB
/
chalk.v
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
module chalk
const (
prefix = '\e['
suffix = 'm'
foreground_colors = {
'black': 30
'red': 31
'green': 32
'yellow': 33
'blue': 34
'magenta': 35
'cyan': 36
'default': 39
'light_gray': 37
'dark_gray': 90
'light_red': 91
'light_green': 92
'light_yellow': 93
'light_blue': 94
'light_magenta': 95
'light_cyan': 96
'white': 97
}
background_colors = {
'black': 40
'red': 41
'green': 42
'yellow': 44
'blue': 44
'magenta': 45
'cyan': 46
'default': 49
'light_gray': 47
'dark_gray': 100
'light_red': 101
'light_green': 102
'light_yellow': 103
'light_blue': 104
'light_magenta': 105
'light_cyan': 106
'white': 107
}
style = {
'bold': 1
'dim': 2
'underline': 4
'blink': 5
'reverse': 7
'hidden': 8
}
reset = '${prefix}0${suffix}'
)
pub fn fg(text string, color string) string {
return '$prefix${foreground_colors[color]}$suffix$text$reset'
}
pub fn bg(text string, color string) string {
return '$prefix${background_colors[color]}$suffix$text$reset'
}
pub fn style(text string, color string) string {
return '$prefix${style[color]}$suffix$text$reset'
}