浏览代码

update rpc generate sample proto file (#1709)

* update rpc generate sample proto file

* update
fang duan 3 年之前
父节点
当前提交
bbe1249ecb
共有 2 个文件被更改,包括 27 次插入2 次删除
  1. 24 2
      tools/goctl/goctl.go
  2. 3 0
      tools/goctl/rpc/cli/cli.go

+ 24 - 2
tools/goctl/goctl.go

@@ -116,7 +116,7 @@ var commands = []cli.Command{
 		Flags: []cli.Flag{
 			cli.StringFlag{
 				Name:  "o",
-				Usage: "the output api file",
+				Usage: "output a sample api file",
 			},
 			cli.StringFlag{
 				Name: "home",
@@ -510,6 +510,28 @@ var commands = []cli.Command{
 	{
 		Name:  "rpc",
 		Usage: "generate rpc code",
+		Flags: []cli.Flag{
+			cli.StringFlag{
+				Name:  "o",
+				Usage: "output a sample proto file",
+			},
+			cli.StringFlag{
+				Name: "home",
+				Usage: "the goctl home path of the template, --home and --remote cannot be set at the same time, " +
+					"if they are, --remote has higher priority",
+			},
+			cli.StringFlag{
+				Name: "remote",
+				Usage: "the remote git repo of the template, --home and --remote cannot be set at the same time, " +
+					"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
+					"https://github.com/zeromicro/go-zero-template directory structure",
+			},
+			cli.StringFlag{
+				Name:  "branch",
+				Usage: "the branch of the remote repo, it does work with --remote",
+			},
+		},
+		Action: rpc.RPCTemplate,
 		Subcommands: []cli.Command{
 			{
 				Name:      "new",
@@ -552,7 +574,7 @@ var commands = []cli.Command{
 				Flags: []cli.Flag{
 					cli.StringFlag{
 						Name:  "out, o",
-						Usage: "the target path of proto",
+						Usage: "the target path of proto (deprecated)",
 					},
 					cli.StringFlag{
 						Name: "home",

+ 3 - 0
tools/goctl/rpc/cli/cli.go

@@ -8,6 +8,7 @@ import (
 	"github.com/urfave/cli"
 	"github.com/zeromicro/go-zero/tools/goctl/rpc/generator"
 	"github.com/zeromicro/go-zero/tools/goctl/util"
+	"github.com/zeromicro/go-zero/tools/goctl/util/console"
 	"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
 )
 
@@ -63,6 +64,8 @@ func RPCNew(c *cli.Context) error {
 
 // RPCTemplate is the entry for generate rpc template
 func RPCTemplate(c *cli.Context) error {
+	console.Warning("deprecated: goctl rpc template -o is deprecated and will be removed in the future, use goctl rpc -o instead")
+
 	if c.NumFlags() == 0 {
 		cli.ShowCommandHelpAndExit(c, "template", 1)
 	}