|
@@ -9,7 +9,6 @@ import (
|
|
|
"github.com/logrusorgru/aurora"
|
|
|
"github.com/tal-tech/go-zero/core/load"
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
- "github.com/tal-tech/go-zero/core/stat"
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/apigen"
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/dartgen"
|
|
|
"github.com/tal-tech/go-zero/tools/goctl/api/docgen"
|
|
@@ -36,6 +35,11 @@ import (
|
|
|
pluginCtl "github.com/zeromicro/protobuf/protoc-gen-go"
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ protocGenGoctl = "protoc-gen-goctl"
|
|
|
+ codeFailure = 1
|
|
|
+)
|
|
|
+
|
|
|
var commands = []cli.Command{
|
|
|
{
|
|
|
Name: "upgrade",
|
|
@@ -646,28 +650,6 @@ var commands = []cli.Command{
|
|
|
},
|
|
|
}
|
|
|
|
|
|
-func main() {
|
|
|
- logx.Disable()
|
|
|
- load.Disable()
|
|
|
- stat.DisableLog()
|
|
|
-
|
|
|
- args := os.Args
|
|
|
- pluginName := filepath.Base(args[0])
|
|
|
- if pluginName == protocGenGoctl {
|
|
|
- pluginCtl.Generate()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- app := cli.NewApp()
|
|
|
- app.Usage = "a cli tool to generate code"
|
|
|
- app.Version = fmt.Sprintf("%s %s/%s", version.BuildVersion, runtime.GOOS, runtime.GOARCH)
|
|
|
- app.Commands = commands
|
|
|
- // cli already print error messages
|
|
|
- if err := app.Run(os.Args); err != nil {
|
|
|
- fmt.Println(aurora.Red(errorx.Wrap(err).Error()))
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func init() {
|
|
|
err := linkProtocGenGoctl()
|
|
|
if err != nil {
|
|
@@ -675,8 +657,6 @@ func init() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const protocGenGoctl = "protoc-gen-goctl"
|
|
|
-
|
|
|
func linkProtocGenGoctl() error {
|
|
|
path, err := env.LookPath("goctl")
|
|
|
if err != nil {
|
|
@@ -698,3 +678,26 @@ func linkProtocGenGoctl() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+func main() {
|
|
|
+ logx.Disable()
|
|
|
+ load.Disable()
|
|
|
+
|
|
|
+ args := os.Args
|
|
|
+ pluginName := filepath.Base(args[0])
|
|
|
+ if pluginName == protocGenGoctl {
|
|
|
+ pluginCtl.Generate()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ app := cli.NewApp()
|
|
|
+ app.Usage = "a cli tool to generate code"
|
|
|
+ app.Version = fmt.Sprintf("%s %s/%s", version.BuildVersion, runtime.GOOS, runtime.GOARCH)
|
|
|
+ app.Commands = commands
|
|
|
+
|
|
|
+ // cli already print error messages
|
|
|
+ if err := app.Run(os.Args); err != nil {
|
|
|
+ fmt.Println(aurora.Red(errorx.Wrap(err).Error()))
|
|
|
+ os.Exit(codeFailure)
|
|
|
+ }
|
|
|
+}
|