MCPcopy Create free account
hub / github.com/exercism/cli / checkForUpdate

Function checkForUpdate

cmd/version.go:52–67  ·  view source on GitHub ↗

checkForUpdate verifies if the CLI is running the latest version. If the client is out of date, the function returns upgrade instructions.

(c *cli.CLI)

Source from the content-addressed store, hash-verified

50// checkForUpdate verifies if the CLI is running the latest version.
51// If the client is out of date, the function returns upgrade instructions.
52func checkForUpdate(c *cli.CLI) (string, error) {
53
54 ok, err := c.IsUpToDate()
55 if err != nil {
56 return "", err
57 }
58
59 if ok {
60 return "Your CLI version is up to date.", nil
61 }
62
63 // Anything but ok is out of date.
64 msg := fmt.Sprintf("A new CLI version is available. Run `exercism upgrade` to update to %s", c.LatestRelease.Version())
65 return msg, nil
66
67}
68
69func init() {
70 RootCmd.AddCommand(versionCmd)

Callers 2

TestVersionUpdateCheckFunction · 0.85
version.goFile · 0.85

Calls 2

VersionMethod · 0.80
IsUpToDateMethod · 0.65

Tested by 1

TestVersionUpdateCheckFunction · 0.68