/
version.go
51 lines (45 loc) · 1.4 KB
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package cmd
import (
"fmt"
"runtime"
"github.com/civo/cli/common"
"github.com/spf13/cobra"
)
const logo = `
_____ _ _____ ___ _____
/ ____| (_) / ____| | | |_ _|
| | _ __ __ ___ | | | | | |
| | | |\ \ / / / _ \ | | | | | |
| |____ | | \ V / | (_) | | |____ | |____ _| |_
\_____||_| \_/ \___/ \_____||______||_____|
`
var (
quiet bool
verbose bool
versionCmd = &cobra.Command{
Use: "version",
Short: "Version will output the current build information",
Run: func(cmd *cobra.Command, args []string) {
switch {
case verbose:
fmt.Printf(logo)
fmt.Printf("Client version: v%s\n", common.VersionCli)
fmt.Printf("Go version (client): %s\n", runtime.Version())
fmt.Printf("Build date (client): %s\n", common.DateCli)
fmt.Printf("Git commit (client): %s\n", common.CommitCli)
fmt.Printf("OS/Arch (client): %s/%s\n", runtime.GOOS, runtime.GOARCH)
common.CheckVersionUpdate()
case quiet:
fmt.Printf("v%s\n", common.VersionCli)
default:
common.CheckVersionUpdate()
fmt.Printf("Civo CLI v%s\n", common.VersionCli)
}
},
}
)
func init() {
rootCmd.AddCommand(versionCmd)
versionCmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "Use quiet output for simple output")
versionCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Use verbose output to see full information")
}