Documentation
¶
Overview ¶
Package updater holds the shared surface for clive's self-update mechanisms. Each mechanism is a sibling subpackage - brew (Homebrew), goinstall (`go install`), and github (release assets) - that describes a tool with its own Config and exposes Check/Update. This package owns the pieces those Configs have in common: the Tool interface that consumers such as notify depend on, and the cross-mechanism UX helpers (Report, UpToDate, Spin), install directory resolution (InstallDir), and subprocess-environment helpers (ProxyBypass, GoPrivate).
It deliberately does not define a behavioural Updater interface over Check/Update: each mechanism's Channel enum differs, and nothing drives an updater polymorphically. The clog dependency lives here and in the subpackages, keeping the core clive package dependency-light.
Index ¶
- Variables
- func DisplayName(name, binary string) string
- func GoPrivate(module, existing string) string
- func Hint(displayName, binaryName, installed, latest string, accent color.Color)
- func HintFor(tool Tool, current, latest string)
- func InstallDir(dir string) string
- func ProxyBypass() []string
- func Report(name string, info clive.Info, old, current string)
- func Spin(ctx context.Context, msg string, fn func(context.Context) error, ...) error
- func UpToDate(name string, info clive.Info, ver string)
- type Field
- type Tool
Constants ¶
This section is empty.
Variables ¶
var DefaultHintColor color.Color = lipgloss.Color("208")
DefaultHintColor is the orange accent for the update hint.
Functions ¶
func DisplayName ¶
DisplayName resolves the human-facing name shown in messages: name when set, else the binary name. Shared by every mechanism's Config.DisplayName.
func GoPrivate ¶
GoPrivate returns a GOPRIVATE value that includes module, preserving any existing entries so the caller's configuration is not discarded. Both inputs are trimmed so surrounding whitespace never yields a malformed list.
func Hint ¶
Hint logs the shared "you're behind" update hint: the 💡 symbol, the installed and latest refs as fields, and a "<name> is outdated! Run `<binary> update` to upgrade" message with the command emphasised in accent. It is the single renderer used by every mechanism's Check and by notify, so the active and passive update paths read identically. installed and latest are already display-formatted.
func HintFor ¶
HintFor logs the default-styled update hint for a tool, formatting current and latest through the tool's VersionLink. It is the convenience each Check uses.
func InstallDir ¶
InstallDir resolves the directory a binary is installed into: dir when set (with a leading "~/" and any env vars expanded), else ~/.local/bin. It returns "" only when no dir was given and the home directory cannot be resolved, letting a caller fall back to a mechanism-specific default.
func ProxyBypass ¶
func ProxyBypass() []string
ProxyBypass returns env entries that disable any inherited proxy for an update subprocess: each proxy variable is blanked (an empty value overrides the inherited one) and NO_PROXY is set to "*" so every host is exempt. Both the upper- and lower-case spellings are set, as tools read either.
func Report ¶
Report logs the result of an update as an old→new pair when the version changed, and otherwise defers to UpToDate. Both old and current may carry a leading "v"; it is stripped before comparison and display.
Types ¶
type Field ¶
Field is an optional structured key/value attached to a Spin message, shown on both the spinner and its completion line (e.g. version="1.2.3").
type Tool ¶
type Tool interface {
// BinaryName is the executable/command name, e.g. "myapp".
BinaryName() string
// DisplayName is the human-facing name shown in messages.
DisplayName() string
// VersionLink renders v as a clickable link to its release/commit.
VersionLink(v string) string
// LatestRef returns the newest installable ref of the tool, fetched over the
// network without a toolchain so a distributed binary can call it. Each
// mechanism answers in its own currency: brew and goinstall report the
// highest semver tag in the repository, while github - which installs release
// assets - reports the latest release's tag, so a consumer's "update
// available" signal matches what the updater can actually fetch. A nil client
// uses [http.DefaultClient].
LatestRef(ctx context.Context, client *http.Client) (string, error)
}
Tool is the metadata a consumer needs to describe a self-updating CLI without depending on how it updates. The brew, goinstall, and github Configs each satisfy it. VersionLink and LatestRef are methods rather than an Info() accessor because Config carries Info as a field, and a struct cannot expose both a field Info and a method Info.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package brew self-updates a Go CLI binary through Homebrew.
|
Package brew self-updates a Go CLI binary through Homebrew. |
|
Package github self-updates a Go CLI binary from its GitHub releases.
|
Package github self-updates a Go CLI binary from its GitHub releases. |
|
Package goinstall self-updates a Go CLI binary through `go install`.
|
Package goinstall self-updates a Go CLI binary through `go install`. |