Return an error if not runnable

This commit is contained in:
Chris Williams 2018-02-26 10:52:51 -08:00
parent a1e4933ab7
commit b3917f15b3

View file

@ -17,6 +17,7 @@ package cobra
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -713,7 +714,7 @@ func (c *Command) execute(a []string) (err error) {
} }
if !c.Runnable() { if !c.Runnable() {
return flag.ErrHelp return errors.New("Subcommand required.")
} }
c.preRun() c.preRun()