exec

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 6 Imported by: 2 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 exec runs external CLI commands behind a small interface so callers can swap a recording mock in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdRunner

type CmdRunner struct {
	DryRun  bool
	Verbose bool
	// Out receives dry-run and verbose log lines; defaults to os.Stderr when nil.
	Out io.Writer
}

CmdRunner executes external CLI commands, with optional dry-run and verbose modes.

func New

func New(dryRun, verbose bool) *CmdRunner

New constructs a CmdRunner.

func (*CmdRunner) Run

func (r *CmdRunner) Run(name string, args ...string) (string, string, error)

Run executes name with args, returning captured stdout and stderr.

func (*CmdRunner) RunDir

func (r *CmdRunner) RunDir(dir string, env []string, name string, args ...string) (string, string, error)

RunDir executes name with args in dir (empty = current dir), appending env.

func (*CmdRunner) RunEnv

func (r *CmdRunner) RunEnv(env []string, name string, args ...string) (string, string, error)

RunEnv executes name with args, appending env to the current process environment.

type Runner

type Runner interface {
	// Run executes name with args, returning captured stdout and stderr.
	Run(name string, args ...string) (string, string, error)
	// RunEnv executes name with args, appending env to the current process environment.
	RunEnv(env []string, name string, args ...string) (string, string, error)
	// RunDir executes name with args in dir (empty = current dir), appending env.
	RunDir(dir string, env []string, name string, args ...string) (string, string, error)
}

Runner executes external CLI commands.

Directories

Path Synopsis
Package exectest provides test doubles for the exec package: a recording MockRunner and a FakeBin helper for tests that need the real exec path.
Package exectest provides test doubles for the exec package: a recording MockRunner and a FakeBin helper for tests that need the real exec path.

Jump to

Keyboard shortcuts

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