formula

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(f *Formula, tmplText string) (string, error)

Generate renders a Ruby formula from the Formula model using the default template, or tmplText if non-empty (a user-supplied override receiving the same model).

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a string to PascalCase for Ruby class names Examples:

  • "myapp" -> "Myapp"
  • "my-app" -> "MyApp"
  • "my_app" -> "MyApp"
  • "myApp" -> "MyApp"

Types

type BinaryInstall added in v0.2.0

type BinaryInstall struct {
	Name        string
	InstallPath string
}

BinaryInstall names a binary and the keg-relative directory it installs into (empty means "bin").

type BottleSpec

type BottleSpec struct {
	Platform string // e.g. "arm64_sonoma", "x86_64_linux"
	SHA256   string // bottle tarball SHA256
	Cellar   string // e.g. ":any_skip_relocation" or an absolute path
}

BottleSpec represents one sha256 line in the bottle block.

type Formula

type Formula struct {
	Name        string // Formula name (e.g., "myapp")
	ClassName   string // PascalCase name for Ruby class (derived if empty)
	Description string // Short description (omitted if empty; brew audit wants it)
	Homepage    string // Project homepage URL
	URL         string // Source tarball URL
	SHA256      string // Source tarball SHA256 (omitted if empty)
	License     string // SPDX identifier (omitted if empty)
	Head        *Head  // Optional head stanza

	// Bottle block
	RootURL string       // e.g. "https://ghcr.io/v2/myorg/tap" (formula name appended by brew)
	Rebuild int          // rebuild counter; emitted as `rebuild N` when > 0
	Bottles []BottleSpec // one line per platform

	// Body
	Dependencies []string        // depends_on lines
	Conflicts    []string        // conflicts_with lines
	Binaries     []BinaryInstall // install lines (first bin-installed binary drives the default test)
	Completions  []string        // completion-generating command rendered per bin-installed binary (empty: no line)
	ExtraInstall []string        // verbatim extra install lines
	Caveats      string          // literal caveats text
	Service      string          // verbatim service block body
	Test         Test            // test block (defaults to `system bin/"<bin>", "--version"`)
}

Formula is the complete model from which a Homebrew formula is generated. gobottle owns the formula outright: every publish renders it from this model; there is no in-place editing of hand-written formulae.

func (*Formula) BinBinaries added in v0.2.0

func (f *Formula) BinBinaries() []string

BinBinaries returns the names of the binaries installed into bin; only these are runnable from PATH, so they drive the default test and completion generation.

type Head struct {
	URL    string // git URL, e.g. https://github.com/owner/repo.git
	Branch string // e.g. "main"
}

Head describes an optional `head` stanza.

type Test

type Test struct {
	Command []string
	Raw     string
}

Test describes the `test do` block. If Raw is set it is used verbatim (indented); otherwise `system bin/"<first binary>", <Command...>` is rendered, with Command defaulting to ["--version"].

Jump to

Keyboard shortcuts

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