hivecli

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package hivecli installs the `hive` command for Hive Desktop: a symlink at ~/.local/bin/hive that points at the desktop executable, which runs the hive CLI when it is invoked under that name. The link is the only record of ownership. The package writes or removes a path only when it is that link, and never touches a `hive` the user installed another way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVersion

func ParseVersion(out string) (string, bool)

ParseVersion reads the first token after "version " in `hive --version` output ("hive version 1.2.3 (abc1234) 2026-01-01").

func RunVersion

func RunVersion(ctx context.Context, path string, env []string, timeout time.Duration) (string, error)

RunVersion returns the output of `<path> --version`.

Types

type Manager

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

Manager reconciles the install path with the user's choice.

func New

func New(opts Options) *Manager

func (*Manager) InstallPath

func (m *Manager) InstallPath() string

InstallPath is where the command lives.

func (*Manager) Reconcile

func (m *Manager) Reconcile(ctx context.Context, enabled *bool) Status

Reconcile makes the install path match enabled and returns the resulting status. A nil enabled means the user was never asked: nothing is written.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context) Status

Status reads the install path and the login shell's view of `hive`.

type Options

type Options struct {
	Home    string
	Version string
	// Executable is the running binary with symlinks resolved. The default is
	// os.Executable followed by filepath.EvalSymlinks.
	Executable func() (string, error)
	// UserPath is the login shell's PATH, without the prefixes the app adds
	// for its own lookups.
	UserPath func(context.Context) string
	// Environ is the environment a probe of `hive --version` runs with.
	Environ func(context.Context) []string
	// Probe returns the output of `<path> --version`.
	Probe  func(ctx context.Context, path string, env []string) (string, error)
	Logger zerolog.Logger
}

Options wires a Manager to its environment. Home, Version, and UserPath are required; the rest have working defaults.

type Owner

type Owner string

Owner says who put the file at the install path.

const (
	OwnerNone    Owner = "none"
	OwnerApp     Owner = "app"
	OwnerForeign Owner = "foreign"
)

type Skip

type Skip string

Skip says why the app does not manage the command on this run.

const (
	SkipNone Skip = ""
	// SkipDev is a development build. Its executable lives in a worktree, so a
	// link to it would break when the checkout moves.
	SkipDev Skip = "dev"
	// SkipTranslocated is a macOS app running from a read-only randomized
	// mount, which disappears when the app quits.
	SkipTranslocated Skip = "translocated"
	// SkipUnwritable is an install directory that cannot be created or written.
	SkipUnwritable Skip = "unwritable"
	// SkipUnrecognizable is an executable the ownership rule would not
	// recognize as the app, so a link to it could never be removed again.
	SkipUnrecognizable Skip = "unrecognizable"
)

type Status

type Status struct {
	// Skip is non-empty when the app is not managing the command, and Detail
	// carries the underlying error for SkipUnwritable.
	Skip   Skip   `json:"skip"`
	Detail string `json:"detail"`
	// InstallPath is where the command lives, Owner who put the file there,
	// and Target the link's destination (empty for a regular file).
	InstallPath string `json:"installPath"`
	Owner       Owner  `json:"owner"`
	Target      string `json:"target"`
	// Resolved is where `hive` leads on the login shell's PATH, empty when
	// nothing does.
	Resolved string `json:"resolved"`
	// Shadowed is true when Resolved is some other file than InstallPath.
	Shadowed bool `json:"shadowed"`
	// OnPath is true when the install directory is on the login shell's PATH.
	OnPath bool `json:"onPath"`
	// AppVersion is this build's version and CommandVersion what Resolved
	// prints, empty when it printed nothing parseable.
	AppVersion     string `json:"appVersion"`
	CommandVersion string `json:"commandVersion"`
	Differs        bool   `json:"differs"`
}

Status is what Settings and first run render.

Jump to

Keyboard shortcuts

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