forked from weaveworks/footloose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
37 lines (30 loc) · 811 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
package main
import (
"fmt"
"strings"
release "github.com/kingdonb/footloose/pkg/version"
"github.com/spf13/cobra"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print footloose version",
Run: showVersion,
}
func init() {
footloose.AddCommand(versionCmd)
}
var version = "git"
func showVersion(cmd *cobra.Command, args []string) {
fmt.Println("version:", version)
if version == "git" {
return
}
release, err := release.FindLastRelease()
if err != nil {
fmt.Println("version: failed to check for new versions. You may want to check yourself at https://github.com/kingdonb/footloose/releases.")
return
}
if strings.Compare(version, *release.TagName) != 0 {
fmt.Printf("New version %v is available. More information at: %v\n", *release.TagName, *release.HTMLURL)
}
}