output

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sanitize added in v0.4.2

func Sanitize(s string) string

Sanitize strips C0 control characters (except tab and newline) from s. This prevents ANSI escape sequences and OSC commands in forge-sourced text from manipulating the terminal.

Types

type Format

type Format string

Format specifies how to render output.

const (
	Table Format = "table"
	JSON  Format = "json"
	Plain Format = "plain"
)

func ParseFormat

func ParseFormat(s string) Format

ParseFormat converts a string flag value to a Format.

type Printer

type Printer struct {
	Format Format
	Out    io.Writer
}

Printer handles formatted output.

func (*Printer) PrintJSON

func (p *Printer) PrintJSON(v any) error

PrintJSON writes v as indented JSON.

func (*Printer) PrintPlain

func (p *Printer) PrintPlain(lines []string)

PrintPlain writes each value on its own line.

func (*Printer) PrintTable

func (p *Printer) PrintTable(headers []string, rows [][]string)

PrintTable writes rows as a tab-aligned table. headers are the column names; rows is a slice of slices where each inner slice is one row.

Jump to

Keyboard shortcuts

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