func (carina *Command) informLatest(pc *kingpin.ParseContext) error { if !carina.CacheEnabled { return nil } ok, err := carina.shouldCheckForUpdate() if !ok { return err } rel, err := version.LatestRelease() if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Unable to fetch information about the latest release of %s. %s\n.", os.Args[0], err) return nil } latest, err := extractSemver(rel.TagName) if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Trouble parsing latest tag (%v): %s\n", rel.TagName, err) return nil } current, err := extractSemver(version.Version) if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Trouble parsing current tag (%v): %s\n", version.Version, err) return nil } if latest.Greater(current) { fmt.Fprintf(os.Stderr, "# A new version of the Carina client is out, go get it\n") fmt.Fprintf(os.Stderr, "# You're on %v and the latest is %v\n", current, latest) fmt.Fprintf(os.Stderr, "# https://github.com/getcarina/carina/releases\n") } return nil }
func informLatest(pc *kingpin.ParseContext) error { if strings.Contains(version.Version, "-dev") || version.Version == "" { fmt.Fprintln(os.Stderr, "# [WARN] In dev mode, not checking for latest release") return nil } rel, err := version.LatestRelease() if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Unable to fetch information about the latest release of %s. %s\n.", os.Args[0], err) return nil } latest, err := extractSemver(rel.TagName) if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Trouble parsing latest tag (%v): %s\n", rel.TagName, err) return nil } current, err := extractSemver(version.Version) if err != nil { fmt.Fprintf(os.Stderr, "# [WARN] Trouble parsing current tag (%v): %s\n", version.Version, err) return nil } if latest.Greater(current) { fmt.Fprintf(os.Stderr, "# A new version of the Carina client is out, go get it\n") fmt.Fprintf(os.Stderr, "# You're on %v and the latest is %v\n", current, latest) fmt.Fprintf(os.Stderr, "# https://github.com/getcarina/carina/releases\n") } return nil }