/
version.go
45 lines (39 loc) · 930 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
34
35
36
37
38
39
40
41
42
43
44
45
package cmd
import (
"github.com/astronomerio/astro-cli/version"
"github.com/spf13/cobra"
)
var (
currVersion string
currCommit string
versionCmd = &cobra.Command{
Use: "version",
Short: "Astronomer CLI version",
Long: "The astro-cli semantic version and git commit tied to that release.",
RunE: printVersion,
}
upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Check for newer version of Astronomer CLI",
Long: "Check for newer version of Astronomer CLI",
RunE: upgradeCheck,
}
)
func init() {
RootCmd.AddCommand(versionCmd)
RootCmd.AddCommand(upgradeCmd)
}
func printVersion(cmd *cobra.Command, args []string) error {
err := version.PrintVersion(currVersion, currCommit)
if err != nil {
return err
}
return nil
}
func upgradeCheck(cmd *cobra.Command, args []string) error {
err := version.CheckForUpdate(currVersion, currCommit)
if err != nil {
return err
}
return nil
}