🔨 Replace color utils with 'github.com/fatih/color'

This commit is contained in:
2025-03-02 20:18:11 +04:00
parent a01bf19986
commit 4cb0540824
6 changed files with 26 additions and 52 deletions

View File

@ -3,46 +3,12 @@ package utils
import (
"fmt"
"os"
"github.com/fatih/color"
)
var Colors = struct {
reset string
Red string
Green string
Yellow string
Orange string
Blue string
Magenta string
Cyan string
Gray string
White string
}{
reset: "\033[0m",
Red: "\033[31m",
Green: "\033[32m",
Yellow: "\033[33m",
Orange: "\033[38;5;208m",
Blue: "\033[34m",
Magenta: "\033[35m",
Cyan: "\033[36m",
Gray: "\033[37m",
White: "\033[97m",
}
func Colored(color string, a ...any) string {
return color + fmt.Sprint(a...) + Colors.reset
}
func PrintfC(color string, format string, a ...any) {
fmt.Printf(Colored(color, format), a...)
}
func PrintlnC(color string, a ...any) {
fmt.Println(Colored(color, a...))
}
func PrintErr(err error) {
PrintlnC(Colors.Red, err.Error())
color.New(color.FgRed).Fprintln(os.Stderr, err.Error())
}
func PrintErrAndExit(err error) {