feat: replaced color package to support Windows (#3207)

This commit is contained in:
ALMAS
2023-05-05 21:09:54 +08:00
committed by GitHub
parent 8ad0668612
commit 774e8d1d08
16 changed files with 55 additions and 85 deletions

View File

@@ -3,10 +3,8 @@ package console
import (
"fmt"
"os"
"runtime"
"github.com/logrusorgru/aurora"
"github.com/zeromicro/go-zero/tools/goctl/vars"
"github.com/gookit/color"
)
type (
@@ -63,32 +61,28 @@ func (c *colorConsole) Debug(format string, a ...any) {
if !c.enable {
return
}
msg := fmt.Sprintf(format, a...)
println(aurora.BrightCyan(msg))
println(color.LightCyan.Sprintf(format, a...))
}
func (c *colorConsole) Success(format string, a ...any) {
if !c.enable {
return
}
msg := fmt.Sprintf(format, a...)
println(aurora.BrightGreen(msg))
println(color.LightGreen.Sprintf(format, a...))
}
func (c *colorConsole) Warning(format string, a ...any) {
if !c.enable {
return
}
msg := fmt.Sprintf(format, a...)
println(aurora.BrightYellow(msg))
println(color.LightYellow.Sprintf(format, a...))
}
func (c *colorConsole) Error(format string, a ...any) {
if !c.enable {
return
}
msg := fmt.Sprintf(format, a...)
println(aurora.BrightRed(msg))
println(color.LightRed.Sprintf(format, a...))
}
func (c *colorConsole) Fatalln(format string, a ...any) {
@@ -126,8 +120,7 @@ func (i *ideaConsole) Info(format string, a ...any) {
}
func (i *ideaConsole) Debug(format string, a ...any) {
msg := fmt.Sprintf(format, a...)
fmt.Println(aurora.BrightCyan(msg))
fmt.Println(color.LightCyan.Sprintf(format, a...))
}
func (i *ideaConsole) Success(format string, a ...any) {
@@ -161,17 +154,6 @@ func (i *ideaConsole) Must(err error) {
}
func println(msg any) {
value, ok := msg.(aurora.Value)
if !ok {
fmt.Println(msg)
}
goos := runtime.GOOS
if goos == vars.OsWindows {
fmt.Println(value.Value())
return
}
fmt.Println(msg)
}