forked from mirror/cobra
Shorter message when invalid flags provided
This commit is contained in:
parent
55ff474dee
commit
6b3d2f2e9a
|
@ -201,7 +201,7 @@ func TestChildCommandFlags(t *testing.T) {
|
|||
t.Errorf("invalid flag should generate error")
|
||||
}
|
||||
|
||||
if !strings.Contains(buf.String(), "inttwo=234") {
|
||||
if !strings.Contains(buf.String(), "unknown shorthand") {
|
||||
t.Errorf("Wrong error message displayed, \n %s", buf.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -149,12 +149,6 @@ func (c *Command) execute(args []string) (err error) {
|
|||
if e == nil {
|
||||
err = cmd.ParseFlags(a)
|
||||
if err != nil {
|
||||
// report flag parsing error
|
||||
c.Println(strings.Split(err.Error(), "\n")[0])
|
||||
erx := cmd.Usage()
|
||||
if erx != nil {
|
||||
return erx
|
||||
}
|
||||
return err
|
||||
} else {
|
||||
argWoFlags := cmd.Flags().Args()
|
||||
|
|
Loading…
Reference in New Issue