/
version.go
33 lines (26 loc) · 714 Bytes
/
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
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// version number is set automatically at build time
var version string
// revision is set automatically use "git rev-parse --short HEAD" at build time
var revision string
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of ca-cli",
Long: `All software has versions. This is ca-cli's`,
Run: func(cmd *cobra.Command, args []string) {
if version == "" {
version = "[Sorry none set at build time.]"
}
if revision == "" {
revision = "[Sorry none set at build time.]"
}
fmt.Printf("Cloud Automator CLI %s (-- HEAD rev: %s)\n", version, revision)
},
}
func init() {
RootCmd.AddCommand(versionCmd)
}