table

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package table renders aligned, borderless tables for CLI output.

It wraps charmbracelet/lipgloss/table with sensible defaults: no borders, automatic terminal width detection, ANSI-aware column sizing, and cell normalization (tabs/newlines → spaces).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CellMaxWidth

func CellMaxWidth() int

CellMaxWidth reports the default maximum width for table cells.

func CellWidth

func CellWidth(value string) int

CellWidth reports the display width of a table cell.

func ColumnPaddingWidth

func ColumnPaddingWidth() int

ColumnPaddingWidth reports the padding between columns.

func Format

func Format(headers []string, rows [][]string) string

Format renders headers and rows as an aligned table.

func OverrideViewportWidth

func OverrideViewportWidth(fn func() int) func()

OverrideViewportWidth replaces the viewport width provider.

func TruncateCell

func TruncateCell(value string) string

TruncateCell limits cell width while preserving visible characters.

func TruncateCellToWidth

func TruncateCellToWidth(value string, max int) string

TruncateCellToWidth limits cell width while preserving visible characters.

func ViewportWidth

func ViewportWidth() int

ViewportWidth reports the configured viewport width.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder collects rows and renders a formatted table.

func NewBuilder

func NewBuilder(headers []string, capacity int) *Builder

NewBuilder returns a builder with preallocated rows.

func (*Builder) AddRow

func (b *Builder) AddRow(row []string)

AddRow appends a row to the table.

func (*Builder) String

func (b *Builder) String() string

String renders the table output.

Jump to

Keyboard shortcuts

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