tee

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinTeeSize      = 500     // Minimum output size to tee (bytes)
	DefaultMaxFiles = 20      // Default max files to keep
	DefaultMaxSize  = 1 << 20 // Default max file size (1MB)
)

Configuration defaults

Variables

This section is empty.

Functions

func FormatHint added in v1.2.0

func FormatHint(path string) string

FormatHint formats a file path as a hint string with ~ shorthand.

func Write added in v1.2.0

func Write(raw string, commandSlug string, exitCode int) string

Write writes using the default tee instance.

func WriteAndHint

func WriteAndHint(raw string, commandSlug string, exitCode int) string

WriteAndHint writes and returns hint using the default tee instance.

Types

type Config

type Config struct {
	Enabled     bool   // Whether tee is enabled
	Mode        Mode   // When to write tee files
	MaxFiles    int    // Maximum number of files to keep
	MaxFileSize int    // Maximum file size in bytes
	Directory   string // Directory for tee files (empty = default)
}

Config configures the tee feature.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default tee configuration.

type Mode

type Mode int

Mode controls when tee writes files.

const (
	ModeNever    Mode = iota // Never write tee files
	ModeFailures             // Write only on command failures (default)
	ModeAlways               // Always write tee files
)

type Tee added in v1.2.0

type Tee struct {
	// contains filtered or unexported fields
}

Tee handles writing raw output to recovery files.

func New added in v1.2.0

func New(config Config) *Tee

New creates a new Tee instance with the given configuration.

func (*Tee) GetDirectory added in v1.2.0

func (t *Tee) GetDirectory() (string, error)

GetDirectory returns the tee directory path.

func (*Tee) ShouldTee added in v1.2.0

func (t *Tee) ShouldTee(rawLen int, exitCode int) bool

ShouldTee determines if output should be tee'd based on config and conditions.

func (*Tee) Write added in v1.2.0

func (t *Tee) Write(raw string, commandSlug string, exitCode int) string

Write writes the raw output to a tee file. Returns the file path if written, or empty string if skipped.

func (*Tee) WriteAndHint added in v1.2.0

func (t *Tee) WriteAndHint(raw string, commandSlug string, exitCode int) string

WriteAndHint writes the raw output and returns a formatted hint.

Jump to

Keyboard shortcuts

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