ui

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ui provides a unified interface for rendering output in different formats. It supports terminal (rich), text (plain), and JSON output formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format int

Format represents the output format type

const (
	// FormatAuto automatically detects the appropriate format based on terminal capabilities
	FormatAuto Format = iota
	// FormatTerminal renders rich terminal output with colors and styling
	FormatTerminal
	// FormatText renders plain text output without any styling
	FormatText
	// FormatJSON renders machine-readable JSON output
	FormatJSON
)

func DetectFormat

func DetectFormat(output *os.File) Format

DetectFormat determines the appropriate output format based on environment and terminal capabilities

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses a string into a Format value

func (Format) String

func (f Format) String() string

String returns the string representation of the format

type Renderer

type Renderer interface {
	// RenderResult renders any result type (command results, execution contexts, etc.)
	RenderResult(result interface{}) error

	// RenderError renders an error with appropriate formatting
	RenderError(err error) error

	// RenderMessage renders a simple message
	RenderMessage(msg string) error
}

Renderer is the common interface for all output renderers. It provides methods for rendering different types of data and messages.

func NewRenderer

func NewRenderer(format Format, output io.Writer) (Renderer, error)

NewRenderer creates a new renderer based on the specified format. It automatically detects terminal capabilities when format is Auto.

Directories

Path Synopsis
Package format provides formatting utilities for UI presentation.
Package format provides formatting utilities for UI presentation.
Package json provides machine-readable JSON output
Package json provides machine-readable JSON output
Package lipbalm provides a simple template engine for rich terminal rendering.
Package lipbalm provides a simple template engine for rich terminal rendering.
Package output implements a declarative, template-based rendering system for dodot's command-line interface.
Package output implements a declarative, template-based rendering system for dodot's command-line interface.
styles
Package styles defines the visual styling for dodot's terminal output.
Package styles defines the visual styling for dodot's terminal output.
Package terminal provides rich terminal output with colors and styling
Package terminal provides rich terminal output with colors and styling
Package text provides plain text output without any styling
Package text provides plain text output without any styling

Jump to

Keyboard shortcuts

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