-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinter.go
31 lines (25 loc) · 837 Bytes
/
printer.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
package printer
import (
"fmt"
"io"
"github.com/fatih/color"
)
var (
ErrorColor = color.New(color.FgRed, color.Bold)
WarningColor = color.New(color.FgYellow, color.Bold)
SuccessColor = color.New(color.FgGreen)
Yellow = color.New(color.FgYellow).SprintFunc()
Cyan = color.New(color.FgCyan).SprintFunc()
)
func Error(w io.Writer, format string, args ...interface{}) error {
_, err := fmt.Fprintf(w, ErrorColor.Sprint("error: ")+Cyan(format)+"\n", args...)
return err
}
func Warning(w io.Writer, format string, args ...interface{}) error {
_, err := fmt.Fprintf(w, WarningColor.Sprint("warning: ")+format+"\n", args...)
return err
}
func Success(w io.Writer, format string, args ...interface{}) error {
_, err := fmt.Fprintf(w, SuccessColor.Sprint("✔ ")+fmt.Sprintf(format+"\n", args...))
return err
}