tools

package
v0.69.3 Latest Latest
Warning

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

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

Documentation

Overview

Package tools resolves the external executables graith shells out to: git, gh, gcx, the notification shell, osascript, ps, and lsof. Historically these names and paths were hard-coded ("git", "gh", "sh", "osascript", "/bin/ps", "/usr/sbin/lsof"), which broke Nix/custom-PATH installs, wrapper binaries, and alternate shells (issue #1238).

A single process-wide resolver holds the effective set. The daemon and the stateless CLI configure it once at startup from the tools config block; every git/store/notification/resource call site then reads it. Reads are lock-free (an atomic snapshot) so the many concurrent daemon goroutines can resolve a tool without contention, and a startup Configure races with nothing because it runs before serving begins.

This is deliberately NOT a generic arbitrary-argv escape hatch: only the executable is configurable. Semantic subcommands (git rev-parse, gh api) and sandbox protocol flags stay in code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(c Config)

Configure installs the effective executable set, filling any empty field with its built-in default. It is intended to run once at startup before the daemon serves requests (or before the CLI runs a command). Calling it with the zero Config restores the built-in defaults.

func GCX added in v0.69.2

func GCX() string

GCX returns the configured Grafana Cloud CLI executable.

func GH

func GH() string

GH returns the configured GitHub CLI executable.

func Git

func Git() string

Git returns the configured git executable.

func Lsof

func Lsof() string

Lsof returns the configured open-files listing executable.

func OSAScript

func OSAScript() string

OSAScript returns the configured osascript executable (macOS notifications).

func PS

func PS() string

PS returns the configured process-listing executable.

func Reset

func Reset()

Reset restores the built-in defaults. It exists for tests that mutate the resolver and need to undo the change.

func Shell

func Shell() string

Shell returns the configured shell used to run notification and trigger commands (invoked as `<shell> -c <command>`).

func Validate

func Validate(c Config) error

Validate checks that every explicitly-set field of c is resolvable, so a misconfigured tool fails loudly at startup rather than at the first git fetch or notification. Empty fields are skipped: a default bare name (e.g. "osascript" on Linux) must retain plain PATH-lookup semantics and is not an error until actually used.

A value containing a path separator (absolute or relative) must point at an existing, regular, executable file. A bare name must be found on PATH.

Types

type Config

type Config struct {
	Git       string
	GH        string
	GCX       string
	Shell     string
	OSAScript string
	PS        string
	Lsof      string
}

Config names each external executable graith may run. A field may be a bare command name resolved on PATH ("git", "hub") or an absolute/relative path to a specific binary ("/run/current-system/sw/bin/git"). An empty field inherits the built-in default from Defaults.

func Defaults

func Defaults() Config

Defaults returns the built-in executable set, preserving the names and paths graith used before they became configurable.

Jump to

Keyboard shortcuts

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