From 2bd8a730ae1986edcd19ee9ca686431cfe78bf2e Mon Sep 17 00:00:00 2001 From: Sascha Holzleiter Date: Thu, 3 Dec 2015 14:58:31 +0100 Subject: [PATCH] always show help if requested, even if SilenceErrors is enabled --- command.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/command.go b/command.go index fe44f449..9b7a006c 100644 --- a/command.go +++ b/command.go @@ -655,13 +655,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) { } err = cmd.execute(flags) if err != nil { + // Always show help if requested, even if SilenceErrors is in + // effect + if err == flag.ErrHelp { + cmd.HelpFunc()(cmd, args) + return cmd, nil + } + // If root command has SilentErrors flagged, // all subcommands should respect it if !cmd.SilenceErrors && !c.SilenceErrors { - if err == flag.ErrHelp { - cmd.HelpFunc()(cmd, args) - return cmd, nil - } c.Println("Error:", err.Error()) }