New version command.
()
| 14 | |
| 15 | // New version command. |
| 16 | func New() *cobra.Command { |
| 17 | return &cobra.Command{ |
| 18 | Use: "version", |
| 19 | Short: "Display detailed version information", |
| 20 | Long: `Displays information about the version of this software.`, |
| 21 | Run: func(cmd *cobra.Command, _ []string) { |
| 22 | var gitInfo string |
| 23 | switch { |
| 24 | case pkg.GitBranch != "" && pkg.GitHash != "": |
| 25 | gitInfo = fmt.Sprintf("@%s-%s", pkg.GitBranch, pkg.GitHash) |
| 26 | case pkg.GitHash != "": |
| 27 | gitInfo = fmt.Sprintf("@%s", pkg.GitHash) |
| 28 | } |
| 29 | fmt.Printf("%s %s%s compiled with %v on %v/%v\n", cmd.Root().Name(), pkg.Version, gitInfo, runtime.Version(), runtime.GOOS, runtime.GOARCH) |
| 30 | }, |
| 31 | } |
| 32 | } |
no test coverage detected