tui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tui owns the CLI's data-presentation contract and the theme it pushes into dry/tui at startup. Operational messaging (Info / Success / Warning / Error) is not wrapped here. Commands call the dry/tui helpers directly for those.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLITheme

func CLITheme() drytheme.Theme

CLITheme returns the safedep-cli theme. main() pushes this into dry/tui as the global default at startup, after which dry/tui Console helpers (Info / Success / Warning / Error / Print) pick it up.

Only warnings and errors carry color. Info and success render with the terminal's default foreground so routine messages do not compete visually with actionable ones.

Types

type Mode

type Mode string

Mode is the user-facing data-output selection. It governs only the data stream on stdout. Messaging on stderr (tui.Info/Success/...) is driven independently by dry/tui's own mode auto-detection.

const (
	ModeTable Mode = "table"
	ModePlain Mode = "plain"
	ModeJSON  Mode = "json"
)

func AutoMode

func AutoMode() Mode

AutoMode returns the auto-detected Mode for the current environment. dry/tui agent mode maps to JSON for data output; rich and plain map to their named equivalents.

func ParseMode

func ParseMode(s string) (Mode, error)

ParseMode validates a user-supplied --output value. Empty input auto-detects from dry/tui's terminal/agent/CI heuristics.

type Printer

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

Printer dispatches a Renderable to stdout in the active Mode.

func NewPrinter

func NewPrinter(mode Mode) *Printer

func (*Printer) Mode

func (p *Printer) Mode() Mode

func (*Printer) Print

func (p *Printer) Print(r Renderable) error

Print writes the Renderable to stdout in the printer's active Mode. JSON bytes are written verbatim with a trailing newline appended when the renderer did not include one.

type Renderable

type Renderable interface {
	RenderJSON() ([]byte, error)
	RenderTable() string
	RenderPlain() string
}

Renderable is implemented by command results that produce structured output. Each method emits the same data in a different format. The dispatcher (Printer.Print) picks one based on the active Mode.

Lists implement the same interface. RenderTable produces a table, RenderPlain emits a line per item, RenderJSON returns the encoded array. Pre-built helpers for common shapes are not provided yet.

Jump to

Keyboard shortcuts

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