homebrew

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package homebrew is the library behind the homebrew command line: the HTTP client and typed data models for the Homebrew formula API at formulae.brew.sh.

Index

Constants

View Source
const DefaultUserAgent = "Mozilla/5.0 (compatible; homebrew-cli/dev; +https://github.com/tamnd/homebrew-cli)"

DefaultUserAgent is the User-Agent sent with every request.

View Source
const Host = "formulae.brew.sh"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cask

type Cask struct {
	Rank     int    `json:"rank"     csv:"rank"     tsv:"rank"`
	Token    string `json:"token"    csv:"token"    tsv:"token"`
	Name     string `json:"name"     csv:"name"     tsv:"name"`
	Desc     string `json:"desc"     csv:"desc"     tsv:"desc"`
	Homepage string `json:"homepage" csv:"homepage" tsv:"homepage"`
	Version  string `json:"version"  csv:"version"  tsv:"version"`
	URL      string `json:"url"      csv:"url"      tsv:"url"`
}

Cask is the public output type for a Homebrew cask.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to formulae.brew.sh over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using cfg.

func (*Client) Cask

func (c *Client) Cask(ctx context.Context, token string) (*Cask, error)

Cask fetches metadata for a single cask by token.

func (*Client) Formula

func (c *Client) Formula(ctx context.Context, name string) (*Formula, error)

Formula fetches metadata for a single formula by name.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunables for a Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Domain

type Domain struct{}

Domain is the homebrew driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Formula

type Formula struct {
	Rank         int      `json:"rank"         csv:"rank"         tsv:"rank"`
	Name         string   `json:"name"         csv:"name"         tsv:"name"`
	FullName     string   `json:"full_name"    csv:"full_name"    tsv:"full_name"`
	Desc         string   `json:"desc"         csv:"desc"         tsv:"desc"`
	License      string   `json:"license"      csv:"license"      tsv:"license"`
	Homepage     string   `json:"homepage"     csv:"homepage"     tsv:"homepage"`
	Version      string   `json:"version"      csv:"version"      tsv:"version"`
	Tap          string   `json:"tap"          csv:"tap"          tsv:"tap"`
	Dependencies []string `json:"dependencies" csv:"dependencies" tsv:"dependencies"`
	URL          string   `json:"url"          csv:"url"          tsv:"url"`
}

Formula is the public output type for a Homebrew formula.

Jump to

Keyboard shortcuts

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