Documentation
¶
Overview ¶
Package installmethod detects how the CLI was installed -- which package manager, installer, or image put the running binary in place -- and maps that to the command that upgrades it, so an out-of-date CLI can tell a user what to run rather than only that a newer version exists.
Index ¶
Constants ¶
const ( APT = "apt" Docker = "docker" Homebrew = "homebrew" NPMGlobal = "npm_global" NPMRun = "npm_run" NPX = "npx" Script = "script" Scoop = "scoop" Unknown = "unknown" Winget = "winget" YUM = "yum" )
The install methods this package reports. Unknown is a value rather than an empty string on purpose: it separates "we looked and could not tell" from a CLI old enough that it reported nothing at all.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
Detect reports how the CLI was installed, or Unknown when no signal matches.
Signals are ordered strongest first: a value the installer set itself, then a method it stamped next to the binary, then the binary's own location, then traces left on the system. Everything after the first two is a heuristic, so the order is what keeps a weaker signal from overriding a better one.
Types ¶
type Advice ¶
type Advice struct {
// Command upgrades the CLI, or is empty for an install method we cannot name
// a command for. Callers should still report that a new version exists in
// that case: knowing to upgrade is useful even without the command, and a
// wrong command is worse than no command.
Command string
// Suppress is set for a channel that resolves the latest version on every
// invocation, where an upgrade notice is noise the user cannot act on.
Suppress bool
}
Advice is what to tell a user whose CLI is out of date.
func UpgradeAdvice ¶
UpgradeAdvice returns what to tell a user running an out-of-date CLI that was installed by the given method. goos is the running platform, which the install scripts' advice depends on; callers pass runtime.GOOS.
type Env ¶
type Env struct {
Getenv func(string) string
Executable func() (string, error)
EvalSymlinks func(string) (string, error)
Stat func(string) error
ReadFile func(string) ([]byte, error)
}
Env describes the host lookups Detect needs. Injected so that tests can drive detection without touching the real environment or filesystem.