Manuscript Documentation
v2026.12.0

@std/cli/table.ms#

Import each required symbol with import Name from "@std/cli/table.ms".

Align Enum#

Horizontal placement of a cell within its column’s measured display width. Example: Table(columns: [Align.Left, Align.Right]).

Manuscript
enum Align {
    Left
    Right
    Center
}

Align.Center#

Splits unused space, putting an odd extra space after the cell.

Manuscript
Center

Align.Left#

Places unused column space after the cell.

Manuscript
Left

Align.Right#

Places unused column space before the cell.

Manuscript
Right

Table Type#

Aligned text columns for terminal output. columns gives one alignment per column; padding is the number of spaces between columns (default 2, negative counts as 0) and indent the spaces before each non-blank line. Rows are added one at a time and rendered as LF-separated lines with no final LF.

Manuscript
import Align, Table from "@std/cli/table.ms"

fn render() String! {
    var table = Table(columns: [Align.Left, Align.Right])
    table.add(["tea", "2"])?
    table.add(["coffee", "30"])?
    return ok(table.render())
}

Unicode widths use String.display_width: cell bytes stay intact and widths are estimates, not a promise for every font or terminal. Cells containing controls (tabs, CR/LF, ESC, C1, U+2028, U+2029) are rejected by add, never expanded or interpreted. Trailing columns whose cells are empty are omitted, so no line ends in added padding; a table without rows renders as “”.

Manuscript
type Table {
    columns List[Align]
    padding Int = 2
    indent Int = 0
    rows List[List[String]] = []
    cell_widths List[List[Int]] = []
    widths List[Int] = []
}

Table.cell_widths#

Internal state: the display width of every cell in rows.

Manuscript
cell_widths List[List[Int]] = []

Table.columns#

One alignment per column; also fixes the number of cells every row must have.

Manuscript
columns List[Align]

Table.indent#

Spaces before each non-blank line.

Manuscript
indent Int = 0

Table.padding#

Spaces between columns; negative counts as 0.

Manuscript
padding Int = 2

Table.rows#

Internal state: the added rows.

Manuscript
rows List[List[String]] = []

Table.widths#

Internal state: the widest cell of each column.

Manuscript
widths List[Int] = []

Table.add#

Appends a row of exactly one cell per column. A wrong cell count or a cell with controls returns EBADMSG.

Manuscript
var fn add(row List[String]) Result[Void, Error]

Table.before#

Spaces placed before a cell: all spare for Right, half for Center, null for Left.

Manuscript
fn before(col Int, spare Int) Int

Table.render#

Lays out the rows added so far; the table is unchanged and can keep growing.

Manuscript
fn render() String