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

@@ -2,53 +2,40 @@ package cmd
import (
"fmt"
"runtime"
"github.com/logrusorgru/aurora"
"github.com/zeromicro/go-zero/tools/goctl/vars"
"github.com/gookit/color"
)
var colorRender = []func(v any) string{
func(v any) string {
return aurora.BrightRed(v).String()
return color.LightRed.Render(v)
},
func(v any) string {
return aurora.BrightGreen(v).String()
return color.LightGreen.Render(v)
},
func(v any) string {
return aurora.BrightYellow(v).String()
return color.LightYellow.Render(v)
},
func(v any) string {
return aurora.BrightBlue(v).String()
return color.LightBlue.Render(v)
},
func(v any) string {
return aurora.BrightMagenta(v).String()
return color.LightMagenta.Render(v)
},
func(v any) string {
return aurora.BrightCyan(v).String()
return color.LightCyan.Render(v)
},
}
func blue(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
return aurora.BrightBlue(s).String()
return color.LightBlue.Render(s)
}
func green(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
return aurora.BrightGreen(s).String()
return color.LightGreen.Render(s)
}
func rainbow(s string) string {
if runtime.GOOS == vars.OsWindows {
return s
}
s0 := s[0]
return colorRender[int(s0)%(len(colorRender)-1)](s)
}