always show help if requested, even if SilenceErrors is enabled

This commit is contained in:
Sascha Holzleiter 2015-12-03 14:58:31 +01:00 committed by Steve Francia
parent c65e6422ff
commit 2bd8a730ae

View file

@ -655,13 +655,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
} }
err = cmd.execute(flags) err = cmd.execute(flags)
if err != nil { if err != nil {
// If root command has SilentErrors flagged, // Always show help if requested, even if SilenceErrors is in
// all subcommands should respect it // effect
if !cmd.SilenceErrors && !c.SilenceErrors {
if err == flag.ErrHelp { if err == flag.ErrHelp {
cmd.HelpFunc()(cmd, args) cmd.HelpFunc()(cmd, args)
return cmd, nil return cmd, nil
} }
// If root command has SilentErrors flagged,
// all subcommands should respect it
if !cmd.SilenceErrors && !c.SilenceErrors {
c.Println("Error:", err.Error()) c.Println("Error:", err.Error())
} }