extensions

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package extensions manages bitbottle CLI extensions: install, list. Extensions are stored under ~/.config/bitbottle/extensions/<name>/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is the HTTP transport interface used by Manager. It is a subset of *http.Client so tests can inject an httptest.Server-backed stub.

type Extension

type Extension struct {
	Manifest
	BinPath string // absolute path to the installed binary / symlink
}

Extension represents an installed extension as returned by List.

type Manager

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

Manager handles extension lifecycle under a root directory.

func New

func New(dir string, client Doer) *Manager

New returns a Manager rooted at dir using client for HTTP requests.

func (*Manager) Exec added in v1.45.0

func (m *Manager) Exec(name string, args []string, token, version string) error

Exec runs the named extension binary with args. It strips env vars whose name (before "=") contains "KEYRING_PASSPHRASE" or "KEYRING_PASSWORD" (case-insensitive), injects BB_TOKEN and BITBOTTLE_VERSION, then delegates to the manager's runner.

Exit-code propagation: callers should check whether the returned error is *exec.ExitError and call os.Exit(ee.ExitCode()) so the shell sees the extension's exit code.

func (*Manager) InstallFromGitHub

func (m *Manager) InstallFromGitHub(ownerRepo string, force bool) error

InstallFromGitHub downloads the latest binary release for owner/repo from GitHub and installs it. If force is false and the extension is already installed it returns an error.

func (*Manager) InstallLocal

func (m *Manager) InstallLocal(path string, force bool) error

InstallLocal symlinks path as an extension. path must be a directory containing a binary named bitbottle-<name> (or its basename is used). The installed name is derived from the last element of path, stripping the "bitbottle-" prefix if present.

func (*Manager) List

func (m *Manager) List() ([]Extension, error)

List returns all installed extensions in alphabetical order.

func (*Manager) Remove added in v1.44.0

func (m *Manager) Remove(name string) error

Remove deletes the named extension entirely.

func (*Manager) Upgrade added in v1.44.0

func (m *Manager) Upgrade(name string, force bool) (oldVer, newVer string, err error)

Upgrade upgrades one named extension to the latest GitHub release. Returns (oldVersion, newVersion, nil) on success. If local: returns ("", "", nil) — skipped. If already at latest and !force: returns (v, v, nil).

func (*Manager) UpgradeAll added in v1.44.0

func (m *Manager) UpgradeAll(force bool) map[string]error

UpgradeAll upgrades every non-local installed extension. Returns map[name]error — nil error means upgraded or already up to date.

func (*Manager) WithRunner added in v1.45.0

func (m *Manager) WithRunner(r func(bin string, args []string, env []string) error) *Manager

WithRunner returns a copy of m with a custom runner (for testing).

type Manifest

type Manifest struct {
	Name    string `json:"name"`
	Repo    string `json:"repo,omitempty"`    // "owner/repo", empty for local
	Version string `json:"version,omitempty"` // tag_name from GitHub, empty for local
	SHA256  string `json:"sha256,omitempty"`  // hex SHA-256 of the binary, empty for local
	Local   bool   `json:"local"`
	// LocalPath is the original source path for local installs.
	LocalPath string `json:"local_path,omitempty"`
}

Manifest is written to <extDir>/<name>/manifest.json after installation.

Jump to

Keyboard shortcuts

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