2018-02-14 09:57:48 -08:00
|
|
|
package version
|
2018-01-18 03:19:41 -08:00
|
|
|
|
2018-01-18 03:38:25 -08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
2018-01-18 03:19:41 -08:00
|
|
|
|
|
|
|
var (
|
2018-01-18 06:34:45 -08:00
|
|
|
// VersionCmd prints out the current sdk version
|
|
|
|
VersionCmd = &cobra.Command{
|
2018-01-18 03:19:41 -08:00
|
|
|
Use: "version",
|
|
|
|
Short: "Print the app version",
|
2018-02-28 23:16:54 -08:00
|
|
|
Run: printVersion,
|
2018-01-18 03:19:41 -08:00
|
|
|
}
|
|
|
|
)
|
2018-01-18 03:38:25 -08:00
|
|
|
|
2018-06-13 22:49:21 -07:00
|
|
|
// return version of CLI/node and commit hash
|
|
|
|
func GetVersion() string {
|
2018-02-14 09:57:48 -08:00
|
|
|
v := Version
|
|
|
|
if GitCommit != "" {
|
2018-04-05 11:02:35 -07:00
|
|
|
v = v + "-" + GitCommit
|
2018-01-18 03:38:25 -08:00
|
|
|
}
|
2018-02-28 23:16:54 -08:00
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// CMD
|
|
|
|
func printVersion(cmd *cobra.Command, args []string) {
|
2018-06-13 22:49:21 -07:00
|
|
|
v := GetVersion()
|
2018-01-18 03:38:25 -08:00
|
|
|
fmt.Println(v)
|
|
|
|
}
|