format

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package format provides the table, YAML, JSON, and "name" output modes used across flate's CLI surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(w io.Writer, value any) error

JSON emits a 2-space-indented JSON document.

func Name

func Name(w io.Writer, items []map[string]string, key string) error

Name emits one resource name per line.

func Table

func Table(w io.Writer, cols []Column, rows []map[string]string) error

Table renders rows of map[string]string into a fixed-width table. Columns are sized to the widest cell + a 4-char gutter. Widths are measured in runes (not bytes) so cells with multi-byte UTF-8 (paths with non-ASCII, chart names with unicode) align correctly. Doesn't account for double-width CJK glyphs — adding a runewidth dependency is out of scope; bring it in when CJK output matters.

func YAML

func YAML(w io.Writer, value any) error

YAML emits a single document.

func YAMLMulti

func YAMLMulti(w io.Writer, docs []map[string]any) error

YAMLMulti emits a multi-document YAML stream.

Types

type Column

type Column struct {
	Header string
	Key    string
}

Column describes a single table column.

type Output

type Output string

Output is the discriminator selected via -o on the CLI.

const (
	OutputTable Output = "table"
	OutputYAML  Output = "yaml"
	OutputJSON  Output = "json"
	OutputName  Output = "name"
)

Output values understood by the -o flag.

Jump to

Keyboard shortcuts

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