add ShowRunErrorUsage flag

Signed-off-by: Pierre-Emmanuel Jacquier <pierre-emmanuel.jacquier@epitech.eu>
This commit is contained in:
Pierre-Emmanuel Jacquier 2018-07-04 15:12:23 +02:00
parent 264fb72ab2
commit d667ccf480

View file

@ -136,6 +136,9 @@ type Command struct {
// SilenceUsage is an option to silence usage when an error occurs.
SilenceUsage bool
// ShowRunErrorUsage is an option to show usage when an error is returned by a RunE function.
ShowRunErrorUsage bool
// DisableFlagParsing disables the flag parsing.
// If this is true all flags will be passed to the command as arguments.
DisableFlagParsing bool
@ -876,7 +879,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
return cmd, nil
}
if cmdErr.CmdErrorType == RunError {
if cmdErr.CmdErrorType == RunError && (!cmd.ShowRunErrorUsage && !c.ShowRunErrorUsage) {
return cmd, cmdErr
}