mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
always show help if requested, even if SilenceErrors is enabled
This commit is contained in:
parent
1c44ec8d3f
commit
f6251f5f3d
1 changed files with 7 additions and 4 deletions
|
@ -661,13 +661,16 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
|||
}
|
||||
err = cmd.execute(flags)
|
||||
if err != nil {
|
||||
// If root command has SilentErrors flagged,
|
||||
// all subcommands should respect it
|
||||
if !cmd.SilenceErrors && !c.SilenceErrors {
|
||||
// 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 {
|
||||
c.Println("Error:", err.Error())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue