Documentation
¶
Overview ¶
Package ptycapture runs subprocesses with optional pseudo-terminal sizing, timeouts, output limits, and stderr handling for documentation tools.
Index ¶
- func ApplyStderrMode(stdout, stderr []byte, mode StderrMode) ([]byte, []byte)
- func CapturePTY(opts Options, argv []string) (stdout, stderr []byte, err error)
- func CapturePlain(opts Options, argv []string) (stdout, stderr []byte, err error)
- func DrainPTYOutput(r io.Reader) ([]byte, error)
- func ExitCode(err error) (int, bool)
- type Options
- type StderrMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyStderrMode ¶
func ApplyStderrMode(stdout, stderr []byte, mode StderrMode) ([]byte, []byte)
ApplyStderrMode merges or discards stderr per mode.
func CapturePTY ¶
CapturePTY runs argv with stdin and stdout on a PTY (fixed cols×rows). stderr is captured with a separate pipe.
func CapturePlain ¶
CapturePlain runs argv with ordinary pipe I/O (no pseudo-terminal).
func DrainPTYOutput ¶
DrainPTYOutput reads remaining PTY output after process exit (exported for tests).
Types ¶
type Options ¶
type Options struct {
Cols uint
Rows uint
Ctx context.Context
Timeout time.Duration
KillAfter time.Duration
MaxOutputBytes int64
}
Options configures subprocess capture.
type StderrMode ¶
type StderrMode int
StderrMode controls how stderr is exposed to callers.
const ( // StderrSeparate keeps stdout and stderr in separate slices. StderrSeparate StderrMode = iota // StderrMerge appends stderr bytes onto stdout. StderrMerge // StderrDiscard drops captured stderr. StderrDiscard )
func ParseStderrMode ¶
func ParseStderrMode(s string) (StderrMode, error)
ParseStderrMode parses -stderr flag values.
Click to show internal directories.
Click to hide internal directories.