Documentation
¶
Index ¶
Constants ¶
const StderrCap = 64 << 10
StderrCap bounds captured stderr. Only its tail is kept: the CLIs write a verbose progress trace there and the error that matters comes last. It is independent of MaxOutputBytes, which callers set to 0 when stdout is a structured stream that must be parsed whole.
const StdoutHardCap = 32 << 20
StdoutHardCap bounds stdout when the caller sets no MaxOutputBytes (the structured JSON/JSONL streams that are parsed whole). Exceeding it sets StdoutTruncated, which those callers treat as an error.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
Command string
Args []string
Dir string
Stdin string
Timeout time.Duration
// MaxOutputBytes caps captured stdout (the head is kept); 0 means "no
// caller cap", which still stops at StdoutHardCap so a runaway CLI cannot
// exhaust memory. Stderr is capped separately: see StderrCap.
MaxOutputBytes int
// StreamTo, if non-nil, means stdout and stderr are also written here live,
// in addition to being captured in the Result.
StreamTo io.Writer
// Env holds extra KEY=VALUE entries appended to the inherited environment
// (later entries win), e.g. to neutralise a tool's config lookups.
Env []string
}
type Result ¶
type Result struct {
Stdout string
Stderr string
// ExitCode is the process exit code; it is -1 when TimedOut is true.
ExitCode int
Elapsed time.Duration
TimedOut bool
// StdoutTruncated reports that stdout exceeded MaxOutputBytes and was cut.
StdoutTruncated bool
// StderrTruncated reports that stderr exceeded StderrCap; Stderr then
// holds only its last StderrCap bytes.
StderrTruncated bool
}