PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.0 KiB

package Color
import (
"fmt"
"regexp"
"runtime"
)
var (
Success = Green
Info = Teal
Warning = Yellow
Fatal = Red
)
var (
Black = Color("\033[1;30m%s\033[0m")
Red = Color("\033[1;31m%s\033[0m")
Green = Color("\033[1;32m%s\033[0m")
Yellow = Color("\033[1;33m%s\033[0m")
Purple = Color("\033[1;34m%s\033[0m")
Magenta = Color("\033[1;35m%s\033[0m")
Teal = Color("\033[1;36m%s\033[0m")
White = Color("\033[1;37m%s\033[0m")
)
func init() {
if runtime.GOOS != "windows" {
return
}
Black = Color("%s")
Red = Color("%s")
Green = Color("%s")
Yellow = Color("%s")
Purple = Color("%s")
Magenta = Color("%s")
Teal = Color("%s")
White = Color("%s")
}
func Color(colorString string) func(...interface{}) string {
sprint := func(args ...interface{}) string {
return fmt.Sprintf(colorString,
fmt.Sprint(args...))
}
return sprint
}
func Strip(s string) string {
var (
reg *regexp.Regexp
res string
)
reg = regexp.MustCompile("\\033\\[.{1,4}m")
res = reg.ReplaceAllString(s, "${1}")
return res
}