output

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package output centralizes harness-owned terminal writes: human-rich vs sparse (--ai-output), and whether stderr supports carriage-return progress (TTY).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Printer

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

Printer writes CLI messages for tools/test. Child processes (go test) still attach os.Stdout/os.Stderr directly where passthrough is intended.

func New

func New(aiOutput bool, stdout, stderr io.Writer, stderrFD uintptr) *Printer

New builds a production Printer. liveInline is enabled when stderrFD points at a real terminal and ai-output is off. Tests should use NewForTest.

func NewForTest

func NewForTest(aiOutput bool, stdout, stderr io.Writer, liveInline bool) *Printer

NewForTest returns a Printer with explicit live-inline behavior. liveInline is ignored when aiOutput is true.

func NewFromApp

func NewFromApp(conf *config.App) *Printer

NewFromApp uses os.Stdout/os.Stderr and stderr's TTY bit from conf.AIOutput.

func (*Printer) AIOutput

func (p *Printer) AIOutput() bool

AIOutput reports sparse / agent-oriented mode.

func (*Printer) ClearInline

func (p *Printer) ClearInline()

ClearInline clears live inline progress lines on stderr when active.

func (*Printer) HumanStderr

func (p *Printer) HumanStderr(a ...any)

HumanStderr writes a line to stderr when in human mode.

func (*Printer) HumanStderrWriter

func (p *Printer) HumanStderrWriter() io.Writer

HumanStderrWriter returns stderr in human mode, io.Discard in AI mode. Use this for helpers that need an io.Writer (e.g. lipgloss tables, hint lines).

func (*Printer) InlineLastLinesForTest added in v0.0.5

func (p *Printer) InlineLastLinesForTest() int

InlineLastLinesForTest returns the tracked wrapped line count after RedrawInline.

func (*Printer) LiveInlineProgress

func (p *Printer) LiveInlineProgress() bool

LiveInlineProgress is true when human mode may use carriage-return redraws on stderr.

func (*Printer) RedrawInline added in v0.0.5

func (p *Printer) RedrawInline(line string)

RedrawInline replaces the live progress block on stderr when live inline mode is active. The line should already be fitted to the terminal width by the caller.

func (*Printer) SetInlineLastLinesForTest added in v0.0.5

func (p *Printer) SetInlineLastLinesForTest(n int)

SetInlineLastLinesForTest sets tracked wrapped line count without a prior draw.

func (*Printer) SetTermColumnsForTest added in v0.0.5

func (p *Printer) SetTermColumnsForTest(cols int)

SetTermColumnsForTest pins TermColumns/RedrawInline width (0 restores default).

func (*Printer) SparseStdoutln

func (p *Printer) SparseStdoutln(a ...any)

SparseStdoutln prints one line to stdout in AI mode (machine-oriented).

func (*Printer) Stderrf

func (p *Printer) Stderrf(format string, a ...any)

Stderrf always writes formatted text to stderr (errors, diagnostics).

func (*Printer) Stdoutln

func (p *Printer) Stdoutln(a ...any)

Stdoutln always writes a line to stdout.

func (*Printer) TermColumns added in v0.0.5

func (p *Printer) TermColumns() int

TermColumns returns stderr width for progress fitting (defaults to 80 when unknown).

Jump to

Keyboard shortcuts

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