brew

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 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
	// KeepOtherInstalls leaves non-Homebrew copies of the binary in place;
	// otherwise they are removed so the brew install is authoritative.
	KeepOtherInstalls bool
}

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.

Jump to

Keyboard shortcuts

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