brew

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package brew self-updates a Go CLI binary through Homebrew. A tool describes itself with a Config and calls Update; it refreshes the formula, then upgrades (or taps and installs), with a stable and a dev (--HEAD) channel, and removes stray non-Homebrew copies so the brew install is authoritative. Check reports whether a newer release exists without installing anything.

It is one update mechanism under clive/update; others (e.g. a release-asset downloader) can sit alongside it. The clog dependency lives here, keeping the core clive package dependency-light for version-only consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, cfg Config) error

Check reports whether a newer release of cfg is available, without installing.

func Update

func Update(ctx context.Context, cfg Config, channel Channel) error

Update installs the latest cfg via Homebrew on the given channel.

Types

type Channel

type Channel int

Channel selects what [Config.Run] installs.

const (
	// Upgrade upgrades an installed formula to its latest version (the default).
	Upgrade Channel = iota
	// Stable installs the latest stable release, replacing any dev build.
	Stable
	// Dev builds and installs the latest source (HEAD).
	Dev
)

func ChannelFor

func ChannelFor(dev, stable bool) Channel

ChannelFor maps a --dev/--stable flag pair to a Channel; neither set is Upgrade.

type Config

type Config struct {
	// Info carries the module path and repo for version checks and release links.
	Info clive.Info
	// Name is the display name shown in messages, e.g. "NGINX" for the nginx
	// formula. Defaults to the binary name (and thus the formula) when unset.
	Name string
	// Formula is the Homebrew formula name.
	Formula string
	// Tap is the "owner/name" tap hosting the formula; empty means a core formula.
	Tap string
	// TapURL is the git remote for Tap, for a private tap brew cannot resolve by
	// name; empty lets brew resolve a public tap.
	TapURL string
	// Binary is the executable name to clean up non-brew copies of; defaults to
	// Formula.
	Binary string
	// OnConflict decides how non-Homebrew copies of the binary on PATH are
	// handled; the zero value warns that each one may shadow the brew install.
	OnConflict ConflictPolicy
}

Config identifies the tool for a Homebrew self-update. Only Info, Name, and Formula are required; Tap/TapURL are needed for a formula outside homebrew/core.

func (Config) BinaryName added in v0.0.9

func (c Config) BinaryName() string

BinaryName is the executable/command name, defaulting to the formula. Shared by other update mechanisms (the periodic check) that name the `<binary> update` command.

func (Config) DisplayName added in v0.0.9

func (c Config) DisplayName() string

DisplayName is the human-facing name used in messages, defaulting to the binary (and thus the formula) name when Name is unset.

type ConflictPolicy added in v0.0.11

type ConflictPolicy int

ConflictPolicy decides what an update does with copies of the binary found on PATH outside Homebrew, which would otherwise shadow the brew install.

const (
	// ConflictWarn leaves stray non-Homebrew copies in place but warns about each
	// one. It is the zero value, and thus the default.
	ConflictWarn ConflictPolicy = iota
	// ConflictUninstall removes stray copies so the brew install is authoritative.
	ConflictUninstall
	// ConflictIgnore leaves stray copies in place silently.
	ConflictIgnore
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL