Documentation
¶
Overview ¶
Package pretty draws a command's result in the pretty format, for a person (docs/designs/cli-pretty.md): a view built from the result's shape by the conventions, adjusted by its fields' pretty tags, then drawn for a terminal.
Index ¶
- func ColorJSON(b []byte, styles cliui.TerminalStyles, tones Tones) []byte
- func ColorYAML(b []byte, styles cliui.TerminalStyles, tones Tones) []byte
- func Render(w io.Writer, v any, width int) error
- func RenderStyled(w io.Writer, v any, width int, styles cliui.TerminalStyles) error
- type Object
- type Tones
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorJSON ¶ added in v0.18.0
func ColorJSON(b []byte, styles cliui.TerminalStyles, tones Tones) []byte
ColorJSON is b, JSON lines as the CLI writes them (each a compact document), colored by ColorYAML's rules: every key bright blue, null and punctuation faint, a URL as a link, a value with a tone in its hue. Only escape codes are added; without styles, b as it is.
func ColorYAML ¶ added in v0.18.0
func ColorYAML(b []byte, styles cliui.TerminalStyles, tones Tones) []byte
ColorYAML is b, YAML as yaml.v3 writes it, colored by cli-pretty.md's rules (docs/designs/cli-pretty.md#color): weight for structure, hue for meaning. Every key is bright blue, siblings alike, the indentation showing what opens a map or a list; null and punctuation faint; a URL as a link; a value with a tone in its hue; any other value plain. Only escape codes are added: removed, they leave b. Without styles (not a terminal, NO_COLOR), b as it is.
func Render ¶
Render writes v, a command's result, in the pretty format, for a terminal of width (0: not a terminal, so nothing is cut). Colors follow w: on a terminal only, not with NO_COLOR.
func RenderStyled ¶ added in v0.18.0
RenderStyled is Render in styles, the terminal's it's bound for: for a view written into a buffer first, to be placed (an error's details, under its headline), which isn't a terminal itself.