From 8157e2118ddbb919053b1936f624761a46da6b62 Mon Sep 17 00:00:00 2001 From: chensy <1278651995@qq.com> Date: Sat, 7 Jan 2023 17:07:40 +0800 Subject: [PATCH] fix: replace goctl ExactValidArgs to MatchAll (#2759) Co-authored-by: chenjieping --- tools/goctl/api/cmd.go | 2 +- tools/goctl/compare/cmd/cmd.go | 2 +- tools/goctl/rpc/cmd.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/goctl/api/cmd.go b/tools/goctl/api/cmd.go index 2218a966..7a190873 100644 --- a/tools/goctl/api/cmd.go +++ b/tools/goctl/api/cmd.go @@ -51,7 +51,7 @@ var ( Use: "new", Short: "Fast create api service", Example: "goctl api new [options] service-name", - Args: cobra.ExactValidArgs(1), + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), RunE: func(cmd *cobra.Command, args []string) error { return new.CreateServiceCommand(args) }, diff --git a/tools/goctl/compare/cmd/cmd.go b/tools/goctl/compare/cmd/cmd.go index 335ee877..ea349b85 100644 --- a/tools/goctl/compare/cmd/cmd.go +++ b/tools/goctl/compare/cmd/cmd.go @@ -9,7 +9,7 @@ import ( var rootCmd = &cobra.Command{ Use: "compare", Short: "Compare the goctl commands generated results between urfave and cobra", - Args: cobra.ExactValidArgs(1), + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), Run: func(cmd *cobra.Command, args []string) { dir := args[0] testdata.MustRun(dir) diff --git a/tools/goctl/rpc/cmd.go b/tools/goctl/rpc/cmd.go index 6beae0de..9f807812 100644 --- a/tools/goctl/rpc/cmd.go +++ b/tools/goctl/rpc/cmd.go @@ -18,7 +18,7 @@ var ( newCmd = &cobra.Command{ Use: "new", Short: "Generate rpc demo service", - Args: cobra.ExactValidArgs(1), + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), RunE: cli.RPCNew, } @@ -34,7 +34,7 @@ var ( Use: "protoc", Short: "Generate grpc code", Example: "goctl rpc protoc xx.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.", - Args: cobra.ExactValidArgs(1), + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), RunE: cli.ZRPC, } )