Sfoglia il codice sorgente

improve goctl rpc new (#1687)

fang duan 3 anni fa
parent
commit
ff6c6558dd
2 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 3 2
      tools/goctl/goctl.go
  2. 4 0
      tools/goctl/rpc/cli/cli.go

+ 3 - 2
tools/goctl/goctl.go

@@ -511,8 +511,9 @@ var commands = []cli.Command{
 		Usage: "generate rpc code",
 		Subcommands: []cli.Command{
 			{
-				Name:  "new",
-				Usage: `generate rpc demo service`,
+				Name:      "new",
+				Usage:     `generate rpc demo service`,
+				UsageText: "example: goctl rpc new [options] service_name",
 				Flags: []cli.Flag{
 					cli.StringFlag{
 						Name:  "style",

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

@@ -14,6 +14,10 @@ import (
 // RPCNew is to generate rpc greet service, this greet service can speed
 // up your understanding of the zrpc service structure
 func RPCNew(c *cli.Context) error {
+	if c.NArg() == 0 {
+		cli.ShowCommandHelpAndExit(c, "new", 1)
+	}
+
 	rpcname := c.Args().First()
 	ext := filepath.Ext(rpcname)
 	if len(ext) > 0 {