feat: Replace cli to cobra (#1855)

* Replace cli

* Replace cli

* Replace cli

* Format code

* Add compare case

* Add compare case

* Add compare case

* Support go style flag

* Support go style flag

* Add test case
This commit is contained in:
anqiansong
2022-05-07 15:40:11 +08:00
committed by GitHub
parent 51472004a3
commit 5383e29ce6
61 changed files with 1858 additions and 1590 deletions

View File

@@ -0,0 +1,10 @@
package upgrade
import "github.com/spf13/cobra"
// Cmd describes a upgrade command.
var Cmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrade goctl to latest version",
RunE: upgrade,
}

View File

@@ -4,13 +4,13 @@ import (
"fmt"
"runtime"
"github.com/urfave/cli"
"github.com/spf13/cobra"
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
)
// Upgrade gets the latest goctl by
// go install github.com/zeromicro/go-zero/tools/goctl@latest
func Upgrade(_ *cli.Context) error {
func upgrade(_ *cobra.Command, _ []string) error {
cmd := `GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go install github.com/zeromicro/go-zero/tools/goctl@latest`
if runtime.GOOS == "windows" {
cmd = `set GOPROXY=https://goproxy.cn,direct && go install github.com/zeromicro/go-zero/tools/goctl@latest`