feat: replaced color package to support Windows (#3207)
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||
@@ -73,6 +73,6 @@ func CreateApiTemplate(_ *cobra.Command, _ []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(aurora.Green("Done."))
|
||||
fmt.Println(color.Green.Render("Done."))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
apiformat "github.com/zeromicro/go-zero/tools/goctl/api/format"
|
||||
@@ -109,7 +109,7 @@ func DoGenProject(apiFile, dir, style string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(aurora.Green("Done."))
|
||||
fmt.Println(color.Green.Render("Done."))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -152,14 +152,14 @@ func sweep() error {
|
||||
seconds, err := strconv.ParseInt(timestamp, 10, 64)
|
||||
if err != nil {
|
||||
// print error and ignore
|
||||
fmt.Println(aurora.Red(fmt.Sprintf("sweep ignored file: %s", fpath)))
|
||||
fmt.Println(color.Red.Sprintf("sweep ignored file: %s", fpath))
|
||||
return nil
|
||||
}
|
||||
|
||||
tm := time.Unix(seconds, 0)
|
||||
if tm.Before(keepTime) {
|
||||
if err := os.RemoveAll(fpath); err != nil {
|
||||
fmt.Println(aurora.Red(fmt.Sprintf("failed to remove file: %s", fpath)))
|
||||
fmt.Println(color.Red.Sprintf("failed to remove file: %s", fpath))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
|
||||
@@ -45,6 +45,6 @@ func JavaCommand(_ *cobra.Command, _ []string) error {
|
||||
logx.Must(genPacket(dir, packetName, api))
|
||||
logx.Must(genComponents(dir, packetName, api))
|
||||
|
||||
fmt.Println(aurora.Green("Done."))
|
||||
fmt.Println(color.Green.Render("Done."))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
|
||||
@@ -45,7 +45,7 @@ func TsCommand(_ *cobra.Command, _ []string) error {
|
||||
|
||||
api, err := parser.Parse(apiFile)
|
||||
if err != nil {
|
||||
fmt.Println(aurora.Red("Failed"))
|
||||
fmt.Println(color.Red.Render("Failed"))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ func TsCommand(_ *cobra.Command, _ []string) error {
|
||||
logx.Must(genHandler(dir, webAPI, caller, api, unwrapAPI))
|
||||
logx.Must(genComponents(dir, api))
|
||||
|
||||
fmt.Println(aurora.Green("Done."))
|
||||
fmt.Println(color.Green.Render("Done."))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/gookit/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
|
||||
)
|
||||
@@ -27,7 +27,7 @@ func GoValidateApi(_ *cobra.Command, _ []string) error {
|
||||
|
||||
err = spec.Validate()
|
||||
if err == nil {
|
||||
fmt.Println(aurora.Green("api format ok"))
|
||||
fmt.Println(color.Green.Render("api format ok"))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user