Skip to main content

Module truncate

Module truncate 

Source
Expand description

Output truncation shared by the tools: by lines and by bytes, from the head or the tail.

Structs§

MiddleTruncation
What truncate_middle kept.
Truncation
What was kept, as stored in tool result details.

Enums§

TruncatedBy
Which limit truncated the output.

Constants§

DEFAULT_MAX_BYTES
Bytes kept by default: 50 KB.
DEFAULT_MAX_LINES
Lines kept by default.
GREP_MAX_LINE_LENGTH
Characters kept per grep match line.

Functions§

format_size
pi’s size format: 512B, 1.5KB, 2.0MB.
tail_bytes
The last max_bytes bytes of text, starting at a character boundary.
truncate_head
Keeps whole lines from the start.
truncate_line
Cuts a line to max_chars UTF-16 units, as pi counts them.
truncate_middle
pi’s truncateMiddle: keeps the start and end of content, half of max_bytes each, with a …N chars truncated… marker between, cutting only at character boundaries.
truncate_tail
Keeps whole lines from the end. A single over-long last line keeps its tail.