execx

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package execx defines the injectable external-command runner the orchestration core uses for git, gh, and host CLIs. Commands are always argument vectors — never shell strings — so external input can never be shell-interpreted. A non-zero exit is data in Result, not an error: callers that need exit codes as information (PRD §16 reproduce-on-base) read them directly, and callers for whom non-zero means failure convert it themselves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// Name is the executable name; the runner resolves it on PATH.
	Name string
	// Args is the argument vector. It is passed verbatim to the
	// process and never shell-interpreted.
	Args []string
	// Dir is the working directory. It is required: an implicit
	// inherited cwd would make command behavior depend on ambient
	// process state, so an empty Dir is an error (fail closed).
	Dir string
	// Env holds KEY=VALUE pairs appended to os.Environ(). Later
	// entries win, so callers can override inherited variables.
	// nil adds nothing.
	Env []string
	// Stdin is the process input; nil means no input.
	Stdin io.Reader
}

Cmd describes one external command invocation.

type Local

type Local struct {
	// LookPath resolves an executable name; defaults to exec.LookPath.
	LookPath func(string) (string, error)
}

Local is the production Runner backed by os/exec.

func (Local) Run

func (l Local) Run(ctx context.Context, c Cmd) (Result, error)

Run executes c and captures its output. The executable is resolved first so a missing binary yields an actionable error instead of a spawn failure.

type Result

type Result struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

Result carries everything a caller needs to interpret an invocation that ran to completion.

type Runner

type Runner interface {
	Run(ctx context.Context, cmd Cmd) (Result, error)
}

Runner runs external commands. Run returns a non-nil error only when the command could not be executed at all (executable missing, context canceled, spawn failure); a command that ran and exited non-zero returns a nil error with the exit code in Result.

Directories

Path Synopsis
Package execxtest provides a scripted fake execx.Runner for transcript tests: each expected call is asserted in order and answered with a recorded result, so tests pin the exact argument vectors the core sends to git and gh without running either.
Package execxtest provides a scripted fake execx.Runner for transcript tests: each expected call is asserted in order and answered with a recorded result, so tests pin the exact argument vectors the core sends to git and gh without running either.

Jump to

Keyboard shortcuts

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