cmdutil

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 12 Imported by: 2 modules, 1 package

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KillProcessGroup added in v0.8.0

func KillProcessGroup(p *exec.Cmd) error

A group already gone is not an error.

func MergeArgs added in v0.4.13

func MergeArgs(sets ...[]string) []string

MergeArgs merges left to right: a repeated flag keeps its first position and its last values (--f=v and --f v are the same flag). Arity is inferred, so repeatable flags collapse and a positional after a flag becomes its value; there is no "--" terminator.

func SetProcessGroup added in v0.8.0

func SetProcessGroup(p *exec.Cmd)

func TerminateProcessGroup added in v0.8.0

func TerminateProcessGroup(p *exec.Cmd) error

A group already gone is not an error.

func UseProcessGroup added in v0.7.0

func UseProcessGroup(p *exec.Cmd)

UseProcessGroup needs an exec.CommandContext command (exec ignores Cancel otherwise); cancel SIGTERMs the group.

Types

type Command

type Command interface {
	Start() error
	// Wait errors before Start and on a second call.
	Wait() error
	Run() error
	// Terminate sends SIGTERM (to the group under WithProcessGroup), or kills where signals are
	// unsupported; an ended command is not an error.
	Terminate() error
	Kill() error
	// Output and Error capture only streams given no writer (bounded by WithMaxBuffer); custom
	// writers are called from exec's goroutines, stdout and stderr concurrently.
	Output() string
	Error() string
	// ExitCode is -1 until Wait returns.
	ExitCode() int
	String() string
}

Command runs once; call Wait once, from one goroutine, and read Output, Error and ExitCode only after it returns.

func New

func New(bin string, args []string, opts ...Option) Command

type Option

type Option func(*cmd)

func WithCancel added in v0.3.13

func WithCancel(fn func(*os.Process) error) Option

func WithContext

func WithContext(ctx context.Context) Option

func WithDir added in v0.3.13

func WithDir(dir string) Option

func WithEnv

func WithEnv(envs ...string) Option

func WithInput

func WithInput(inputs ...io.Reader) Option

WithInput with no readers passes the parent's stdin; without WithInput stdin is the null device.

func WithMaxBuffer added in v0.3.13

func WithMaxBuffer(n int) Option

func WithProcessGroup added in v0.7.0

func WithProcessGroup() Option

func WithStderr added in v0.3.13

func WithStderr(w io.Writer) Option

func WithStdout added in v0.3.13

func WithStdout(w io.Writer) Option

func WithWaitDelay added in v0.3.13

func WithWaitDelay(d time.Duration) Option

Jump to

Keyboard shortcuts

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