Documentation
¶
Overview ¶
Package extensions manages bitbottle CLI extensions: install, list. Extensions are stored under ~/.config/bitbottle/extensions/<name>/.
Index ¶
- type Doer
- type Extension
- type Manager
- func (m *Manager) Exec(name string, args []string, token, version string) error
- func (m *Manager) InstallFromGitHub(ownerRepo string, force bool) error
- func (m *Manager) InstallLocal(path string, force bool) error
- func (m *Manager) List() ([]Extension, error)
- func (m *Manager) Remove(name string) error
- func (m *Manager) Upgrade(name string, force bool) (oldVer, newVer string, err error)
- func (m *Manager) UpgradeAll(force bool) map[string]error
- func (m *Manager) WithRunner(r func(bin string, args []string, env []string) error) *Manager
- type Manifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doer ¶
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 (*Manager) Exec ¶ added in v1.45.0
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 ¶
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 ¶
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) Upgrade ¶ added in v1.44.0
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
UpgradeAll upgrades every non-local installed extension. Returns map[name]error — nil error means upgraded or already up to date.
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.