Documentation
¶
Overview ¶
Package updatecheck reports whether a newer GitHub release of a CLI exists and how to upgrade it via the package manager that installed it. It never touches the binary — the actual upgrade is delegated to the package manager (see ADR-0005).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheFile ¶ added in v0.14.0
CacheFile is the conventional update-check cache path for app — the hint writes it and WhatsNewCommand reads it as its offline fallback. "" if the user cache dir is unavailable.
func WhatsNewCommand ¶ added in v0.13.0
func WhatsNewCommand(cfg WhatsNewConfig) *cobra.Command
WhatsNewCommand returns a `whatsnew` cobra command that renders the release notes for every version newer than the running build, glamour-rendered. See forge ADR-0012.
Types ¶
type Checker ¶
type Checker struct {
Repo string // "owner/name"
BaseURL string // "" → https://api.github.com
Client *http.Client // nil → a client with a 5s timeout
}
Checker queries a GitHub repo's latest release.
type Hinter ¶
type Hinter struct {
Repo string // "owner/name"
Bin string // binary name: the hint label and brew/mise/scoop command
Module string // `go install` target path (used only when go-installed)
Current string // current version
CacheFile string // "" → always fetch (no cache)
OptOutEnv string // env var that disables the hint when set to "false"
Skip func() bool // optional app gate; hint skipped when it returns true (run-time)
BaseURL string // "" → https://api.github.com (test seam)
Client *http.Client // nil → default
Now func() time.Time // nil → time.Now (test seam)
}
Hinter prints a one-line upgrade hint when a newer release exists, fetching at most once per 24h (when CacheFile is set). Every error is swallowed — the hint must never break a normal run.
func (Hinter) PostRun ¶ added in v0.14.0
PostRun returns a cobra PersistentPostRunE that prints the upgrade hint after each command, unless this is a dev build (Current == "dev"), OptOutEnv is set to "false", or the optional Skip gate returns true. It bounds the check to hintTimeout and swallows errors, so every tool wires the hint identically: root.PersistentPostRunE = Hinter{…}.PostRun().
type InstallMethod ¶
type InstallMethod int
InstallMethod is how a binary was installed, inferred from its path.
const ( Unknown InstallMethod = iota Homebrew Mise Scoop GoInstall )
func DetectInstall ¶
func DetectInstall() InstallMethod
DetectInstall infers how the running executable was installed by resolving its real path and matching known package-manager locations.
func (InstallMethod) UpgradeCommand ¶
func (m InstallMethod) UpgradeCommand(bin, module string) string
UpgradeCommand returns the command to upgrade bin via this install method, or "" for Unknown (callers fall back to a generic message). module is the `go install` target path, used only for GoInstall.
type WhatsNewConfig ¶ added in v0.13.0
type WhatsNewConfig struct {
Repo string // "owner/name"
Current string // running version
CacheFile string // offline fallback source ("" → no fallback)
Changelog string // embedded changelog markdown, the last offline fallback ("" → none)
BaseURL string // "" → https://api.github.com
Client *http.Client // nil → default
Now func() time.Time // nil → time.Now
}
WhatsNewConfig parameterises WhatsNewCommand for one tool. Repo and Current are required; CacheFile enables the offline fallback, and BaseURL/Client/Now are test seams.