github.com/webonyx/up@v0.7.4-0.20180808230834-91b94e551323/internal/colors/colors.go (about) 1 // Package colors provides colors used by the CLI. 2 package colors 3 4 import ( 5 "fmt" 6 7 color "github.com/aybabtme/rgbterm" 8 ) 9 10 // Func is a color function. 11 type Func func(string) string 12 13 // Bold string. 14 func Bold(s string) string { 15 return fmt.Sprintf("\x1b[1m%s\x1b[m", s) 16 } 17 18 // Gray string. 19 func Gray(s string) string { 20 return color.FgString(s, 150, 150, 150) 21 } 22 23 // Blue string. 24 func Blue(s string) string { 25 return color.FgString(s, 77, 173, 247) 26 } 27 28 // Cyan string. 29 func Cyan(s string) string { 30 return color.FgString(s, 34, 184, 207) 31 } 32 33 // Green string. 34 func Green(s string) string { 35 return color.FgString(s, 0, 200, 255) 36 } 37 38 // Red string. 39 func Red(s string) string { 40 return color.FgString(s, 194, 37, 92) 41 } 42 43 // Yellow string. 44 func Yellow(s string) string { 45 return color.FgString(s, 252, 196, 25) 46 } 47 48 // Purple string. 49 func Purple(s string) string { 50 return color.FgString(s, 96, 97, 190) 51 } 52 53 // Bool returns a color func based on the state. 54 func Bool(ok bool) Func { 55 if ok { 56 return Purple 57 } 58 59 return Red 60 }