From 86783686cade7a5ea7f5306d461d91841c7a6b3d Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Sat, 2 Dec 2017 09:59:49 -0800 Subject: [PATCH] Add documentation for '--version' flag to README (#590) --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 11bc5eca..9f20a0b7 100644 --- a/README.md +++ b/README.md @@ -560,6 +560,13 @@ cmd.SetUsageFunc(f func(*Command) error) cmd.SetUsageTemplate(s string) ``` +## Version Flag + +Cobra adds a top-level '--version' flag if the Version field is set on the root command. +Running an application with the '--version' flag will print the version to stdout using +the version template. The template can be customized using the +`cmd.SetVersionTemplate(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: