ui

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ui provides a structured, tag-prefixed printer for user-facing stderr output.

All user-facing narrative output (progress, status, warnings) should be written via Printer so it is consistently tagged and goes to stderr, keeping stdout clean for machine-consumed payloads (__TREEPAD_CD__, JSON, config dumps).

Error contract: any non-zero exit must emit exactly one [ERR] line on stderr describing the user-actionable problem. Individual commands return plain errors; the [ERR] tag is applied at the top-level boundary in cmd/tp/main.go.

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 fixed-width tagged lines to an io.Writer. A nil Printer is safe to use; all calls are no-ops.

func New

func New(w io.Writer) *Printer

New returns a Printer that writes to w. Debug output is enabled when TREEPAD_DEBUG is set to a non-empty value.

func (*Printer) Debug

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

func (*Printer) Err

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

func (*Printer) Info

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

func (*Printer) OK

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

func (*Printer) Prompt

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

Prompt writes a bare prompt string to stderr without a trailing newline or tag. Used for interactive confirmation prompts where a tag would look odd.

func (*Printer) Step

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

func (*Printer) Warn

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

func (*Printer) Writer

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

Writer returns the underlying io.Writer. Returns io.Discard if the Printer is nil or has no writer.

Jump to

Keyboard shortcuts

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