github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/version/version.go (about) 1 package version 2 3 import ( 4 "fmt" 5 "runtime" 6 7 "github.com/henvic/wedeploycli/defaults" 8 "github.com/henvic/wedeploycli/verbose" 9 "github.com/spf13/cobra" 10 ) 11 12 // VersionCmd is used for reading the version of this tool 13 var VersionCmd = &cobra.Command{ 14 Use: "version", 15 Args: cobra.NoArgs, 16 Run: versionRun, 17 Short: "Show CLI version", 18 } 19 20 // Print the current version 21 func Print() { 22 var os = runtime.GOOS 23 var arch = runtime.GOARCH 24 fmt.Printf( 25 "Liferay Cloud Platform CLI version %s %s/%s\n", 26 defaults.Version, 27 os, 28 arch) 29 30 if defaults.Build != "" { 31 fmt.Printf("Build commit: %v\n", defaults.Build) 32 } 33 34 if defaults.BuildTime != "" { 35 fmt.Printf("Build time: %v\n", defaults.BuildTime) 36 } 37 38 verbose.Debug("Go version:", runtime.Version()) 39 } 40 41 func versionRun(cmd *cobra.Command, args []string) { 42 Print() 43 }