mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Merge pull request #244 from apriendeau/silence-errors-readme
updates readme to Explain SilenceErrors and SilenceUsage #225
This commit is contained in:
commit
57021c6b4d
1 changed files with 6 additions and 1 deletions
|
@ -713,7 +713,8 @@ func main() {
|
||||||
|
|
||||||
## Alternative Error Handling
|
## Alternative Error Handling
|
||||||
|
|
||||||
Cobra also has functions where the return signature is an error. This allows for errors to bubble up to the top, providing a way to handle the errors in one location. The current list of functions that return an error is:
|
Cobra also has functions where the return signature is an error. This allows for errors to bubble up to the top,
|
||||||
|
providing a way to handle the errors in one location. The current list of functions that return an error is:
|
||||||
|
|
||||||
* PersistentPreRunE
|
* PersistentPreRunE
|
||||||
* PreRunE
|
* PreRunE
|
||||||
|
@ -721,6 +722,10 @@ Cobra also has functions where the return signature is an error. This allows for
|
||||||
* PostRunE
|
* PostRunE
|
||||||
* PersistentPostRunE
|
* PersistentPostRunE
|
||||||
|
|
||||||
|
If you would like to silence the default `error` and `usage` output in favor of your own, you can set `SilenceUsage`
|
||||||
|
and `SilenceErrors` to `false` on the command. A child command respects these flags if they are set on the parent
|
||||||
|
command.
|
||||||
|
|
||||||
**Example Usage using RunE:**
|
**Example Usage using RunE:**
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
Loading…
Reference in a new issue