From fae133554dc5857b3d06e556fbcb0b03ebbf4d60 Mon Sep 17 00:00:00 2001 From: spf13 Date: Tue, 5 Nov 2013 20:04:51 -0500 Subject: [PATCH] Fixing error messaging when upstream flag library is inconsistent. --- command.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/command.go b/command.go index 69a9bf3..6841004 100644 --- a/command.go +++ b/command.go @@ -265,6 +265,7 @@ func (c *Command) execute(a []string) (err error) { } err = c.ParseFlags(a) + if err != nil { return err } else { @@ -574,15 +575,15 @@ func (c *Command) ParseFlags(args []string) (err error) { c.mergePersistentFlags() err = c.Flags().Parse(args) - if err != nil { - return err - } + // The upstream library adds spaces to the error // response regardless of success. // Handling it here until fixing upstream if len(strings.TrimSpace(c.flagErrorBuf.String())) > 1 { return fmt.Errorf("%s", c.flagErrorBuf.String()) } + + //always return nil because upstream library is inconsistent & we always check the error buffer anyway return nil }