Shorter message when invalid flags provided

This commit is contained in:
spf13 2013-09-29 02:01:56 -04:00
parent 55ff474dee
commit 6b3d2f2e9a
2 changed files with 1 additions and 7 deletions

View file

@ -201,7 +201,7 @@ func TestChildCommandFlags(t *testing.T) {
t.Errorf("invalid flag should generate error") 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()) t.Errorf("Wrong error message displayed, \n %s", buf.String())
} }

View file

@ -149,12 +149,6 @@ func (c *Command) execute(args []string) (err error) {
if e == nil { if e == nil {
err = cmd.ParseFlags(a) err = cmd.ParseFlags(a)
if err != nil { 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 return err
} else { } else {
argWoFlags := cmd.Flags().Args() argWoFlags := cmd.Flags().Args()