From ff6c6558ddc55a08d5924952ba00d3e152179cb6 Mon Sep 17 00:00:00 2001 From: fang duan Date: Sun, 17 Apr 2022 20:56:56 +0800 Subject: [PATCH] improve goctl rpc new (#1687) --- tools/goctl/goctl.go | 5 +++-- tools/goctl/rpc/cli/cli.go | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/goctl/goctl.go b/tools/goctl/goctl.go index 69f98487..15dc8ed7 100644 --- a/tools/goctl/goctl.go +++ b/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", diff --git a/tools/goctl/rpc/cli/cli.go b/tools/goctl/rpc/cli/cli.go index b45f202a..7d76c1ef 100644 --- a/tools/goctl/rpc/cli/cli.go +++ b/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 {