utils

package
v0.82.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxLines    = 2000
	DefaultMaxBytes    = 50 * 1024
	GrepMaxLineLength  = 500
	TruncatedByLines   = "lines"
	TruncatedByBytes   = "bytes"
	TruncatedByNothing = ""
)

Variables

This section is empty.

Functions

func SanitizeBinaryOutput added in v0.82.0

func SanitizeBinaryOutput(text string) string

func TruncateLine

func TruncateLine(line string, maxChars int) (string, bool)

Types

type ShellCaptureOptions added in v0.82.0

type ShellCaptureOptions struct {
	CWD                   string
	Env                   map[string]string
	InheritEnv            bool
	Timeout               time.Duration
	OnChunk               func(chunk string, progress func() ShellCaptureProgress)
	ReturnExecutionErrors bool
}

type ShellCaptureProgress added in v0.82.0

type ShellCaptureProgress struct {
	Output         string
	Truncation     TruncationResult
	FullOutputPath string
	LastLineBytes  int
}

type ShellCaptureResult added in v0.82.0

type ShellCaptureResult struct {
	ShellCaptureProgress
	ExitCode       *int
	Cancelled      bool
	ExecutionError *harnessenv.ExecutionError
}

func ExecuteShellWithCapture added in v0.82.0

func ExecuteShellWithCapture(ctx context.Context, env harnessenv.ExecutionEnv, command string, options ShellCaptureOptions) (ShellCaptureResult, error)

type TruncationOptions

type TruncationOptions struct {
	MaxLines int
	MaxBytes int
}

type TruncationResult

type TruncationResult struct {
	Content               string
	Truncated             bool
	TruncatedBy           string
	TotalLines            int
	TotalBytes            int
	OutputLines           int
	OutputBytes           int
	LastLinePartial       bool
	FirstLineExceedsLimit bool
	MaxLines              int
	MaxBytes              int
}

func TruncateHead

func TruncateHead(content string, options TruncationOptions) TruncationResult

func TruncateTail

func TruncateTail(content string, options TruncationOptions) TruncationResult

Jump to

Keyboard shortcuts

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