Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
(currentVersion string)
| 27 | // Execute adds all child commands to the root command and sets flags appropriately. |
| 28 | // This is called by main.main(). It only needs to happen once to the rootCmd. |
| 29 | func Execute(currentVersion string) error { |
| 30 | rootCmd.Version = currentVersion |
| 31 | info := version.FetchUpdateInfo(rootCmd.Version) |
| 32 | defer info.PromptUpdateIfAvailable() |
| 33 | ctx := version.WithContext(context.Background(), &info) |
| 34 | return rootCmd.ExecuteContext(ctx) |
| 35 | } |
| 36 | |
| 37 | func init() { |
| 38 | cobra.OnInitialize(initConfig) |
no test coverage detected