From a76559e04a52ad85993dfe276b91591ad54c4b76 Mon Sep 17 00:00:00 2001 From: 5ouma <101255979+5ouma@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:06:32 +0900 Subject: [PATCH] [update] Doc to use `errPrefix` Description to change it and what it is. --- site/content/user_guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/content/user_guide.md b/site/content/user_guide.md index 56e8e44a..03972bb9 100644 --- a/site/content/user_guide.md +++ b/site/content/user_guide.md @@ -596,6 +596,12 @@ Running an application with the '--version' flag will print the version to stdou the version template. The template can be customized using the `cmd.SetVersionTemplate(s string)` function. +## Error Message Prefix + +Cobra prints an error message when being returned a non-nil error value. +The default error message is `Error: error contents`. +The Prefix, `Error:` can be customized using the `cmd.SetErrPrefix(s string)` function. + ## PreRun and PostRun Hooks It is possible to run functions before or after the main `Run` function of your command. The `PersistentPreRun` and `PreRun` functions will be executed before `Run`. `PersistentPostRun` and `PostRun` will be executed after `Run`. The `Persistent*Run` functions will be inherited by children if they do not declare their own. These functions are run in the following order: