truncate

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxLines   = 2000
	DefaultMaxBytes   = 50 * 1024
	GrepMaxLineLength = 500
)

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(bytes int) string

func Int

func Int(value int) *int

Types

type LineResult

type LineResult struct {
	Text         string `json:"text"`
	WasTruncated bool   `json:"wasTruncated"`
}

func TruncateLine

func TruncateLine(line string, maxChars ...int) LineResult

type Options

type Options struct {
	MaxLines *int `json:"maxLines,omitempty"`
	MaxBytes *int `json:"maxBytes,omitempty"`
}

Options uses pointers because zero is an upstream-visible limit, while nil means the option was omitted and selects the default.

type Reason

type Reason string
const (
	ReasonLines Reason = "lines"
	ReasonBytes Reason = "bytes"
)

type Result

type Result struct {
	Content               string  `json:"content"`
	Truncated             bool    `json:"truncated"`
	TruncatedBy           *Reason `json:"truncatedBy"`
	TotalLines            int     `json:"totalLines"`
	TotalBytes            int     `json:"totalBytes"`
	OutputLines           int     `json:"outputLines"`
	OutputBytes           int     `json:"outputBytes"`
	LastLinePartial       bool    `json:"lastLinePartial"`
	FirstLineExceedsLimit bool    `json:"firstLineExceedsLimit"`
	MaxLines              int     `json:"maxLines"`
	MaxBytes              int     `json:"maxBytes"`
}

func TruncateHead

func TruncateHead(content string, options ...Options) Result

func TruncateTail

func TruncateTail(content string, options ...Options) Result

Jump to

Keyboard shortcuts

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