Documentation
¶
Overview ¶
Package paru implements the dotdrift mise package-plugin backend for the `paru` manager (pacman + AUR). The dotdrift paru subcommand exposes two operations — installed (status check) and install — that the Lua plugin shim delegates to. This keeps all paru invocation logic in Go.
Index ¶
- Variables
- func EnsureInstalled(misePluginsDir, name string) (bool, error)
- func FormatStatus(states []State) string
- func Install(ctx context.Context, runner Runner, names []string, dryRun, update bool) error
- func InstallArgs(names []string, dryRun, update bool) []string
- func WritePlugin(dir string) error
- type ExecRunner
- type Runner
- type State
Constants ¶
This section is empty.
Variables ¶
var PluginVersion = func() string { data, err := fs.ReadFile(pluginRoot, "metadata.lua") if err != nil { return "unknown" } m := versionRe.FindSubmatch(data) if len(m) < 2 { return "unknown" } return string(m[1]) }()
PluginVersion is the version declared in the embedded metadata.lua, parsed at package init so log output references the real version without a hand-maintained constant.
Functions ¶
func EnsureInstalled ¶ added in v0.13.0
EnsureInstalled copies the embedded paru plugin into mise's plugin registry (misePluginsDir/name) as real files — the same on-disk shape as any other mise plugin, no symlink — but performs no writes on the common path. It hashes the installed plugin and compares to the embedded plugin's hash, recopying (remove + rewrite) only on mismatch, a missing plugin, or when the target is a symlink (a stale shape left by an older dotdrift). Call on every Arch apply; returns true when it wrote.
func FormatStatus ¶
FormatStatus emits the line-based protocol consumed by the Lua plugin shim: one line per package, tab-separated: name<TAB>installed|missing<TAB>version.
func Install ¶
Install runs `paru -S --needed --noconfirm <names>`. paru self-elevates (calls sudo pacman internally); this function invokes no sudo itself.
func InstallArgs ¶
InstallArgs builds the argv for installing packages via paru.
func WritePlugin ¶
WritePlugin writes the embedded paru plugin into dir, preserving its layout. Creates directories as needed; overwrites existing files (content is deterministic — same embed, same bytes).
Types ¶
type ExecRunner ¶
type ExecRunner struct {
// Out/Err are the streaming destinations; nil defaults to
// os.Stdout/os.Stderr.
Out io.Writer
Err io.Writer
}
ExecRunner runs commands via exec.CommandContext. Run captures combined output (the probe path — pacman -Q); RunStream wires the child's stdout/stderr straight to Out/Err so its output streams live (the install path), echoing the command line set -x-style ("+ argv") to Err before execution. Fakes implement only Runner, so they stay on the captured path untouched.
func (ExecRunner) Run ¶
Run executes name with args, returning trimmed stdout on success or the combined output on failure (so callers surface the tool's own diagnostics).
func (ExecRunner) RunStream ¶ added in v0.19.0
RunStream wires the child's stdout/stderr straight to Out/Err so its output streams live (the install path), echoing the command line set -x-style ("+ argv") to Err before execution. The paru install command is always verbose — mise invokes it as a fresh subprocess whose output would otherwise be captured and discarded. Streaming returns no captured output (the terminal already shows it).
type Runner ¶
Runner executes one command and returns its stdout (trimmed) on success or the combined output on failure.
type State ¶
State is one element of the installed-status response.
func PackageStatus ¶
PackageStatus checks each package via `pacman -Q <name>`. The query is read-only and never elevates. A package present in pacman's local database (covering both repo and AUR packages) is "installed"; anything else is "missing". Errors from individual queries are tolerated (treated as missing) so one bad name never blocks the batch.