Skip to content

Commit

Permalink
Merge pull request #3733 from r-vasquez/rpk-usage-for-invalid-args
Browse files Browse the repository at this point in the history
rpk/cli: show help for incorrect number or invalid arguments
  • Loading branch information
twmb committed Mar 25, 2022
2 parents c2a39fd + ca17253 commit eeab718
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
9 changes: 4 additions & 5 deletions src/go/rpk/pkg/cli/cmd/acl.go
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/go/rpk/pkg/cli/cmd/debug/bundle.go
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/go/rpk/pkg/cli/cmd/redpanda/check.go
Expand Up @@ -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)
},
Expand Down
1 change: 0 additions & 1 deletion src/go/rpk/pkg/cli/cmd/redpanda/stop.go
Expand Up @@ -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)
},
Expand Down
1 change: 0 additions & 1 deletion src/go/rpk/pkg/cli/cmd/root.go
Expand Up @@ -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).")

Expand Down
7 changes: 3 additions & 4 deletions src/go/rpk/pkg/cli/cmd/version.go
Expand Up @@ -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())
Expand Down
7 changes: 3 additions & 4 deletions src/go/rpk/pkg/cli/cmd/wasm/generate.go
Expand Up @@ -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)
Expand Down

0 comments on commit eeab718

Please sign in to comment.