mirror of
https://github.com/spf13/cobra
synced 2025-05-06 13:27:26 +00:00
add ShowRunErrorUsage flag
Signed-off-by: Pierre-Emmanuel Jacquier <pierre-emmanuel.jacquier@epitech.eu>
This commit is contained in:
parent
264fb72ab2
commit
d667ccf480
1 changed files with 4 additions and 1 deletions
|
@ -136,6 +136,9 @@ type Command struct {
|
||||||
// SilenceUsage is an option to silence usage when an error occurs.
|
// SilenceUsage is an option to silence usage when an error occurs.
|
||||||
SilenceUsage bool
|
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.
|
// DisableFlagParsing disables the flag parsing.
|
||||||
// If this is true all flags will be passed to the command as arguments.
|
// If this is true all flags will be passed to the command as arguments.
|
||||||
DisableFlagParsing bool
|
DisableFlagParsing bool
|
||||||
|
@ -876,7 +879,7 @@ func (c *Command) ExecuteC() (cmd *Command, err error) {
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmdErr.CmdErrorType == RunError {
|
if cmdErr.CmdErrorType == RunError && (!cmd.ShowRunErrorUsage && !c.ShowRunErrorUsage) {
|
||||||
return cmd, cmdErr
|
return cmd, cmdErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue