Display an error when help is called on a non existing command.
This commit is contained in:
parent
68ecf78f0e
commit
a34876d700
2 changed files with 21 additions and 5 deletions
|
@ -86,6 +86,11 @@ func execute(cmd *Command, args []string, root bool) error {
|
|||
}
|
||||
|
||||
func run(cmd *Command, args []string) error {
|
||||
if len(args) > 0 && !isFlag(args[0]) && !cmd.AllowArg {
|
||||
_ = PrintHelp(os.Stdout, cmd)
|
||||
return fmt.Errorf("command not found: %s", args[0])
|
||||
}
|
||||
|
||||
if isHelp(args) {
|
||||
return PrintHelp(os.Stdout, cmd)
|
||||
}
|
||||
|
@ -95,11 +100,6 @@ func run(cmd *Command, args []string) error {
|
|||
return fmt.Errorf("command %s is not runnable", cmd.Name)
|
||||
}
|
||||
|
||||
if len(args) > 0 && !isFlag(args[0]) && !cmd.AllowArg {
|
||||
_ = PrintHelp(os.Stdout, cmd)
|
||||
return fmt.Errorf("command not found: %v", args)
|
||||
}
|
||||
|
||||
if cmd.Configuration == nil {
|
||||
return cmd.Run(args)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue