cloudflare/pint
Publicmirrored from https://github.com/cloudflare/pintAvailable
internal/output/output.go
49lines · modecode
| 1 | package output |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "io" |
| 6 | |
| 7 | "github.com/fatih/color" |
| 8 | ) |
| 9 | |
| 10 | var ( |
| 11 | redColor = color.New(color.FgRed) |
| 12 | blueColor = color.New(color.FgCyan) |
| 13 | whiteColor = color.New(color.FgWhite) |
| 14 | yellowColor = color.New(color.FgYellow) |
| 15 | magnetaColor = color.New(color.FgMagenta) |
| 16 | grayColor = color.New(color.FgHiBlack) |
| 17 | ) |
| 18 | |
| 19 | func Info(output io.Writer, msg string) { |
| 20 | fmt.Fprintln(output, msg) |
| 21 | } |
| 22 | |
| 23 | func Error(output io.Writer, err error) { |
| 24 | redColor.Fprintln(output, err.Error()) |
| 25 | } |
| 26 | |
| 27 | func MakeRed(format string, a ...interface{}) string { |
| 28 | return redColor.Sprintf(format, a...) |
| 29 | } |
| 30 | |
| 31 | func MakeBlue(format string, a ...interface{}) string { |
| 32 | return blueColor.Sprintf(format, a...) |
| 33 | } |
| 34 | |
| 35 | func MakeWhite(format string, a ...interface{}) string { |
| 36 | return whiteColor.Sprintf(format, a...) |
| 37 | } |
| 38 | |
| 39 | func MakeYellow(format string, a ...interface{}) string { |
| 40 | return yellowColor.Sprintf(format, a...) |
| 41 | } |
| 42 | |
| 43 | func MakeMagneta(format string, a ...interface{}) string { |
| 44 | return magnetaColor.Sprintf(format, a...) |
| 45 | } |
| 46 | |
| 47 | func MakeGray(format string, a ...interface{}) string { |
| 48 | return grayColor.Sprintf(format, a...) |
| 49 | } |
| 50 | |