-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.go
45 lines (37 loc) · 1012 Bytes
/
color.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
package result
import (
"fmt"
"github.com/fatih/color"
)
var green = color.New(color.FgGreen).SprintFunc()
var red = color.New(color.FgRed).SprintFunc()
var cyan = color.New(color.FgCyan).SprintFunc()
// PrintOK prints a success message.
// A newline is appended.
func PrintOK(message string) {
fmt.Printf("%s %s\n", green("[OK]"), message)
}
// PrintError prints an error message.
// A newline is appended.
func PrintError(message string) {
fmt.Printf("%s %s\n", red("[ERROR]"), message)
}
// PrintRed prints a message in red.
// A newline is appended.
func PrintRed(message string) {
fmt.Printf("%s\n", red(message))
}
// PrintInfo prints an info message.
// A newline is appended.
func PrintInfo(message string) {
color.Cyan(message)
}
// Describe prints the name in color, and the shortDesc using normal color.
// A newline is appended.
func Describe(name, shortDesc string) {
if shortDesc == "" {
fmt.Printf("%s\n", cyan(name))
} else {
fmt.Printf("%s %s\n", cyan(name), shortDesc)
}
}