table

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package table provides a terminal table renderer backed by lipgloss. Consumers supply data via the TableData interface rather than building lipgloss tables directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCell

func FormatCell(v any) string

FormatCell converts a value to a display string for a table cell. It handles nil, empty strings, zero values, time formatting, and Bold wrapping.

func Render

func Render(data TableData) string

Render renders the table data as a string suitable for terminal output. Columns are auto-sized to the terminal width with word wrapping enabled.

func RenderMarkdown

func RenderMarkdown(data TableData) string

RenderMarkdown renders the table data as a Markdown table string, suitable for platforms that render markdown (Telegram, terminal with glamour).

func Truncate

func Truncate(s string, max int) string

Truncate shortens s to max runes, collapsing newlines and appending "…" if truncated.

Types

type Bold

type Bold struct{ Value any }

Bold wraps a cell value so that FormatCell renders it in bold.

type TableData

type TableData interface {
	// Header returns the column header labels.
	Header() []string

	// Len returns the number of rows.
	Len() int

	// Row returns the cell values for row i. Values are converted to
	// strings via FormatCell. Return nil to skip a row.
	// Wrap a value in Bold{} to render it in bold.
	Row(i int) []any
}

TableData is the interface that data sources implement to be rendered as a terminal table.

Jump to

Keyboard shortcuts

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