Skip to content
Myr

Fixing error messaging when upstream flag library is inconsistent.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by spf13 · committed by spf13 · parent 2f19d3c · Browse files · 1 file+4 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:command.go+4 added-3 removed
263 unmodified lines
264 return fmt.Errorf("Called Execute() on a nil Command")265 }266267 err = c.ParseFlags(a)268269 if err != nil {270 return err271 } else {272 argWoFlags := c.Flags().Args()
301 unmodified lines
574func (c *Command) ParseFlags(args []string) (err error) {575 c.mergePersistentFlags()576577 err = c.Flags().Parse(args)577 if err != nil {578 return err579 }578579 // The upstream library adds spaces to the error580 // response regardless of success.581 // Handling it here until fixing upstream582 if len(strings.TrimSpace(c.flagErrorBuf.String())) > 1 {583 return fmt.Errorf("%s", c.flagErrorBuf.String())584 }585586 //always return nil because upstream library is inconsistent & we always check the error buffer anyway587 return nil588}589590func (c *Command) mergePersistentFlags() {
21 unmodified lines