Documentation
¶
Overview ¶
Package table provides a reusable interactive table viewer and output formatters. It supports an interactive TUI (with search, column expand/hide, smooth scrolling), plain text tables, JSON output, and raw tab-separated output.
This package is used by both `pgit sql` and `pgit analyze` to display tabular results.
Index ¶
- func DisplayResults(title string, columns []string, rows [][]string, opts DisplayOptions) error
- func PadOrTruncate(s string, width int) string
- func PrintJSONResults(colNames []string, rows [][]string) error
- func PrintPlainTable(colNames []string, rows [][]string)
- func RunTableTUI(title string, columns []string, rows [][]string) error
- func Truncate(s string, width int) string
- type DisplayOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayResults ¶
func DisplayResults(title string, columns []string, rows [][]string, opts DisplayOptions) error
DisplayResults picks the right output mode based on options and environment, then renders the given columns and rows. The title is shown in the interactive TUI header; for non-interactive modes it is ignored.
func PadOrTruncate ¶
PadOrTruncate pads or truncates to exact width (for TUI table).
func PrintJSONResults ¶
PrintJSONResults outputs results as a JSON array of objects.
func PrintPlainTable ¶
PrintPlainTable prints a properly aligned table for non-TTY output. Shows full content without truncation.
func RunTableTUI ¶
RunTableTUI launches the interactive table viewer. It blocks until the user quits. If the user requests an export (J/R/P), the data is printed to stdout after the TUI exits.
Types ¶
type DisplayOptions ¶
type DisplayOptions struct {
// JSON outputs results as a JSON array of objects.
JSON bool
// Raw outputs results as tab-separated values (for piping).
Raw bool
// NoPager forces plain table output even on a TTY.
NoPager bool
}
DisplayOptions controls how results are rendered.