From 6b3d2f2e9abfc6c216f4e346bc5cbffacc8a4b29 Mon Sep 17 00:00:00 2001 From: spf13 Date: Sun, 29 Sep 2013 02:01:56 -0400 Subject: [PATCH] Shorter message when invalid flags provided --- cobra_test.go | 2 +- command.go | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cobra_test.go b/cobra_test.go index e6551e00..001c8256 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -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()) } diff --git a/command.go b/command.go index ce4557de..b8e47814 100644 --- a/command.go +++ b/command.go @@ -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()