Documentation
¶
Overview ¶
Package render turns a diff.Result into something a person or a script can read: colored terminal output, a side-by-side table, JSON, or a CSV of just the rows that changed.
Index ¶
- func CSV(w io.Writer, r *diff.Result, o Options) error
- func ColorEnabled(mode string) bool
- func JSON(w io.Writer, r *diff.Result, o Options) error
- func SideBySide(w io.Writer, r *diff.Result, o Options) error
- func TerminalWidth() int
- func Text(w io.Writer, r *diff.Result, o Options) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSV ¶
CSV writes only the rows that changed, tagged with what happened to them. A modified row appears twice, once with its old values and once with its new ones, so nothing is lost on export.
func ColorEnabled ¶
ColorEnabled decides whether to emit ANSI codes, honouring NO_COLOR and FORCE_COLOR before falling back to whether stdout is a terminal.
func JSON ¶
JSON writes the whole result as one object. Every list is present even when empty, so consumers never have to guard against null.
func SideBySide ¶
SideBySide lays every change out as a three-column table: the column name, its value in the old file, and its value in the new one.
func TerminalWidth ¶
func TerminalWidth() int
TerminalWidth reports a usable output width, preferring the real terminal size and falling back to COLUMNS and then to a sane default.