From ca1725376c84dc2fa717d1ee852a10036ce80c52 Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Thu, 3 Feb 2022 16:41:41 -0500 Subject: [PATCH] rpk/cli: show help for incorrect number or invalid arguments --- src/go/rpk/pkg/cli/cmd/acl.go | 9 ++++----- src/go/rpk/pkg/cli/cmd/debug/bundle.go | 1 - src/go/rpk/pkg/cli/cmd/redpanda/check.go | 5 ++--- src/go/rpk/pkg/cli/cmd/redpanda/stop.go | 1 - src/go/rpk/pkg/cli/cmd/root.go | 1 - src/go/rpk/pkg/cli/cmd/version.go | 7 +++---- src/go/rpk/pkg/cli/cmd/wasm/generate.go | 7 +++---- 7 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/go/rpk/pkg/cli/cmd/acl.go b/src/go/rpk/pkg/cli/cmd/acl.go index 31ddf5a7efae..3e929dbeb26d 100644 --- a/src/go/rpk/pkg/cli/cmd/acl.go +++ b/src/go/rpk/pkg/cli/cmd/acl.go @@ -38,11 +38,10 @@ func NewACLCommand(fs afero.Fs, mgr config.Manager) *cobra.Command { helpOperations bool ) command := &cobra.Command{ - Use: "acl", - Short: "Manage ACLs and SASL users.", - Long: helpACLs, - SilenceUsage: true, - Args: cobra.ExactArgs(0), + Use: "acl", + Short: "Manage ACLs and SASL users.", + Long: helpACLs, + Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, _ []string) { if helpOperations { fmt.Println(helpACLOperations) diff --git a/src/go/rpk/pkg/cli/cmd/debug/bundle.go b/src/go/rpk/pkg/cli/cmd/debug/bundle.go index 9e744de5e321..0add51e756f2 100644 --- a/src/go/rpk/pkg/cli/cmd/debug/bundle.go +++ b/src/go/rpk/pkg/cli/cmd/debug/bundle.go @@ -255,7 +255,6 @@ The following are the data sources that are bundled in the compressed file: - dmidecode: The DMI table contents. Only included if this command is run as root. `, - SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { p := config.ParamsFromCommand(cmd) cfg, err := p.Load(fs) diff --git a/src/go/rpk/pkg/cli/cmd/redpanda/check.go b/src/go/rpk/pkg/cli/cmd/redpanda/check.go index 00bc043393ef..0ffd67f65cd3 100644 --- a/src/go/rpk/pkg/cli/cmd/redpanda/check.go +++ b/src/go/rpk/pkg/cli/cmd/redpanda/check.go @@ -32,9 +32,8 @@ func NewCheckCommand(fs afero.Fs, mgr config.Manager) *cobra.Command { timeout time.Duration ) command := &cobra.Command{ - Use: "check", - Short: "Check if system meets redpanda requirements.", - SilenceUsage: true, + Use: "check", + Short: "Check if system meets redpanda requirements.", RunE: func(ccmd *cobra.Command, args []string) error { return executeCheck(fs, mgr, configFile, timeout) }, diff --git a/src/go/rpk/pkg/cli/cmd/redpanda/stop.go b/src/go/rpk/pkg/cli/cmd/redpanda/stop.go index 12420a0f0624..8f608f2e3013 100644 --- a/src/go/rpk/pkg/cli/cmd/redpanda/stop.go +++ b/src/go/rpk/pkg/cli/cmd/redpanda/stop.go @@ -38,7 +38,6 @@ func NewStopCommand(fs afero.Fs, mgr config.Manager) *cobra.Command { first sends SIGINT, and waits for the specified timeout. Then, if redpanda hasn't stopped, it sends SIGTERM. Lastly, it sends SIGKILL if it's still running.`, - SilenceUsage: true, RunE: func(ccmd *cobra.Command, args []string) error { return executeStop(fs, mgr, configFile, timeout) }, diff --git a/src/go/rpk/pkg/cli/cmd/root.go b/src/go/rpk/pkg/cli/cmd/root.go index c15f80c2bf73..783e2f7f4b7e 100644 --- a/src/go/rpk/pkg/cli/cmd/root.go +++ b/src/go/rpk/pkg/cli/cmd/root.go @@ -59,7 +59,6 @@ func Execute() { Short: "rpk is the Redpanda CLI & toolbox.", Long: "", } - rootCmd.SilenceUsage = true rootCmd.PersistentFlags().BoolVarP(&verbose, config.FlagVerbose, "v", false, "Enable verbose logging (default: false).") diff --git a/src/go/rpk/pkg/cli/cmd/version.go b/src/go/rpk/pkg/cli/cmd/version.go index c89a8177fc90..338dedf04ea4 100644 --- a/src/go/rpk/pkg/cli/cmd/version.go +++ b/src/go/rpk/pkg/cli/cmd/version.go @@ -18,10 +18,9 @@ import ( func NewVersionCommand() *cobra.Command { command := &cobra.Command{ - Use: "version", - Short: "Check the current version.", - Long: "", - SilenceUsage: true, + Use: "version", + Short: "Check the current version.", + Long: "", Run: func(_ *cobra.Command, _ []string) { log.SetFormatter(cli.NewNoopFormatter()) log.Infof("%s\n", version.Pretty()) diff --git a/src/go/rpk/pkg/cli/cmd/wasm/generate.go b/src/go/rpk/pkg/cli/cmd/wasm/generate.go index 30c3b4e780ed..16651519ede7 100644 --- a/src/go/rpk/pkg/cli/cmd/wasm/generate.go +++ b/src/go/rpk/pkg/cli/cmd/wasm/generate.go @@ -31,10 +31,9 @@ func NewGenerateCommand(fs afero.Fs) *cobra.Command { skipVersion bool ) cmd := &cobra.Command{ - Use: "generate [PROJECT DIRECTORY]", - Short: "Create an npm template project for inline WASM engine.", - SilenceUsage: true, - Args: cobra.ExactArgs(1), + Use: "generate [PROJECT DIRECTORY]", + Short: "Create an npm template project for inline WASM engine.", + Args: cobra.ExactArgs(1), Run: func(_ *cobra.Command, args []string) { path, err := filepath.Abs(args[0]) out.MaybeDie(err, "unable to get absolute path for %q: %v", args[0], err)