terminal_table/builders

Incremental construction for data whose shape is known at runtime.

Types

TableBuilder = object
  headers*: seq[string]
  rows*: seq[seq[string]]
  currentRow*: seq[string]
Accumulates rows before validating and producing a Table.

Procs

proc addCell(builder: var TableBuilder; value: string) {....raises: [], tags: [],
    forbids: [].}
Appends one cell to the row currently being assembled.
proc addRow(builder: var TableBuilder; values: varargs[string, `$`]) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Appends one complete dynamic row.
proc build(builder: TableBuilder): Table {....raises: [ValueError], tags: [],
    forbids: [].}
Validates the accumulated shape and returns an independent table.
proc finishRow(builder: var TableBuilder) {....raises: [ValueError], tags: [],
    forbids: [].}
Finishes the current row. Empty rows are rejected.
proc fromRows(rows: openArray[seq[string]]): Table {....raises: [ValueError],
    tags: [], forbids: [].}
Builds a headerless table from runtime row data.
proc initTableBuilder(headers: openArray[string] = []): TableBuilder {.
    ...raises: [], tags: [], forbids: [].}
Starts a dynamic table builder, optionally with a header.