|
1 | 1 | package utils |
2 | 2 |
|
3 | | -import "github.com/gookit/color" |
| 3 | +import "github.com/mgutz/ansi" |
4 | 4 |
|
5 | | -func Black(a ...interface{}) string { |
6 | | - return color.Black.Render(a...) |
7 | | -} |
8 | | - |
9 | | -func White(a ...interface{}) string { |
10 | | - return color.White.Render(a...) |
11 | | -} |
12 | | - |
13 | | -func Gray(a ...interface{}) string { |
14 | | - return color.Gray.Render(a...) |
15 | | -} |
16 | | - |
17 | | -func Red(a ...interface{}) string { |
18 | | - return color.Red.Render(a...) |
19 | | -} |
| 5 | +var Black = ansi.ColorFunc("black") |
| 6 | +var White = ansi.ColorFunc("white") |
20 | 7 |
|
21 | | -func Green(a ...interface{}) string { |
22 | | - return color.Green.Render(a...) |
| 8 | +func Gray(arg string) string { |
| 9 | + return ansi.Color(ansi.LightBlack+arg, "") |
23 | 10 | } |
24 | 11 |
|
25 | | -func Yellow(a ...interface{}) string { |
26 | | - return color.Yellow.Render(a...) |
27 | | -} |
28 | | - |
29 | | -func Blue(a ...interface{}) string { |
30 | | - return color.Blue.Render(a...) |
31 | | -} |
32 | | - |
33 | | -func Magenta(a ...interface{}) string { |
34 | | - return color.Magenta.Render(a...) |
35 | | -} |
36 | | - |
37 | | -func Cyan(a ...interface{}) string { |
38 | | - return color.Cyan.Render(a...) |
39 | | -} |
| 12 | +var Red = ansi.ColorFunc("red") |
| 13 | +var Green = ansi.ColorFunc("green") |
| 14 | +var Yellow = ansi.ColorFunc("yellow") |
| 15 | +var Blue = ansi.ColorFunc("blue") |
| 16 | +var Magenta = ansi.ColorFunc("magenta") |
| 17 | +var Cyan = ansi.ColorFunc("cyan") |
40 | 18 |
|
41 | | -func Bold(a ...interface{}) string { |
42 | | - return color.Bold.Render(a...) |
| 19 | +func Bold(arg string) string { |
| 20 | + // This is really annoying. If you just define Bold as ColorFunc("+b") it will properly bold but |
| 21 | + // will not use the default color, resulting in black and probably unreadable text. This forces |
| 22 | + // the default color before bolding. |
| 23 | + return ansi.Color(ansi.DefaultFG+arg, "+b") |
43 | 24 | } |
0 commit comments