Documentation
¶
Overview ¶
Package update provides self-update functionality for the Mush CLI.
It wraps the go-selfupdate library to check for and apply updates from GitHub Releases with checksum verification.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDisabled ¶
func IsDisabled() bool
IsDisabled returns true if update checks are disabled via MUSH_UPDATE_DISABLED.
func NeedsElevation ¶
NeedsElevation returns true if the binary's parent directory is not writable.
func ReExecWithSudo ¶
func ReExecWithSudo() error
ReExecWithSudo re-launches the current command under sudo. This replaces the current process via syscall.Exec.
Types ¶
type Info ¶
type Info struct {
CurrentVersion string `json:"currentVersion"`
LatestVersion string `json:"latestVersion"`
UpdateAvailable bool `json:"updateAvailable"`
ReleaseURL string `json:"releaseURL,omitempty"`
// Release is the underlying release metadata (nil if not available).
Release *selfupdate.Release `json:"-"`
}
Info holds the result of a version check.
type State ¶
type State struct {
LastCheckedAt time.Time `json:"lastCheckedAt"`
LatestVersion string `json:"latestVersion,omitempty"`
CurrentVersion string `json:"currentVersion,omitempty"`
ReleaseURL string `json:"releaseURL,omitempty"`
}
State holds cached update check results.
func LoadState ¶
LoadState reads the state file. Returns zero-value State if the file doesn't exist.
func (*State) HasUpdate ¶
HasUpdate returns true if the cached latest version is newer than current.
func (*State) ShouldCheck ¶
ShouldCheck returns true if enough time has passed since the last check.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater manages checking for and applying updates.
func NewUpdater ¶
NewUpdater creates a new Updater configured for GitHub Releases.
func (*Updater) Apply ¶
Apply downloads and installs the given release, replacing the current binary.
func (*Updater) ApplyVersion ¶
ApplyVersion downloads and installs a specific version.