feat: replaced color package to support Windows (#3207)
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/withfig/autocomplete-tools/integrations/cobra"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/api"
|
||||
@@ -44,7 +44,7 @@ var (
|
||||
func Execute() {
|
||||
os.Args = supportGoStdFlag(os.Args)
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(aurora.Red(err.Error()))
|
||||
fmt.Println(color.Red.Render(err.Error()))
|
||||
os.Exit(codeFailure)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user