render

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package render writes what commands produce: JSON for programs (design §5), and, from milestone 2, tables for people.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignRight

func AlignRight(headers []string, rows [][]string, cols ...int)

AlignRight pads the cells of the columns cols on the left, so they line up on their right edge, as amounts should. The header counts toward the width. tabwriter can only align every column one way; this does one at a time, before Table pads them all on the right.

func Fields

func Fields(w io.Writer, fields [][2]string) error

Fields writes label and value pairs, one a line, values lined up: the layout `quantic stock` uses too, for `quantic auth status`.

func JSON

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

JSON writes v as indented JSON followed by a newline. Indented because a person reads it too (piped to less, pasted in an issue); a program doesn't care either way. The trailing newline is what every Unix tool expects of a line of output, and what json.Encoder adds by itself.

HTML escaping is off: by default Go writes "AT&T" as "AT\u0026T", which is valid JSON and right inside an HTML page, and wrong in a terminal.

func Or

func Or(s *string) string

Or returns *s, or "-" when s is nil or blank: how a table shows a value Quantic doesn't have. Runs of spaces inside s collapse to one, because some names come from exchanges padded to a fixed width.

func Table

func Table(w io.Writer, headers []string, rows [][]string) error

Table writes rows under headers in columns, two spaces apart, for people. text/tabwriter does the aligning: each cell ends at a tab, and it pads the cells of a column to the widest. The last cell of a row has no tab after it, so no line ends in spaces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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