Skip to content

Upgrade notice

Currently, the upgrade notice works only for GitHub releases.

Tip

Want to try? See the upgrade notice examples!

The upgrade notice is disabled by default. You can easily enable it based on your usage:

  • Printer

    p := printer.New(
      printer.WithUpgradeNotice("mszostok", "codeowners-validator", upgradeOpts...),
    )
    

    It prints the notice to the standard error channel (stderr). As a result, output processing, such as executing <cli> -ojson | jq .gitCommit, works properly even if the upgrade notice is displayed.

  • Cobra CLI

    extension.NewVersionCobraCmd(
        // 2. Explicit turn on upgrade notice
        extension.WithUpgradeNotice("mszostok", "codeowners-validator"),
    ),
    

    It prints the notice on standard error channel (stderr). As a result, output processing, such as executing <cli> version -ojson | jq .gitCommit, works properly even if the upgrade notice is displayed.

  • Standalone

    notice := upgrade.NewGitHubDetector("mszostok", "codeowners-validator")
    err := notice.PrintIfFoundGreater(os.Stderr, "0.5.4")
    

Once enabled, each execution checks for new releases but only once every 24 hours. If a newer version has been found, it displays an upgrade notice for each output format to the standard error channel (stderr).

You can customize almost all aspects of the upgrade check. See customization for more details.

Back to top