table

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 12 Imported by: 0

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

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

func PadOrTruncate(s string, width int) string

PadOrTruncate pads or truncates to exact width (for TUI table).

func PrintJSONResults

func PrintJSONResults(colNames []string, rows [][]string) error

PrintJSONResults outputs results as a JSON array of objects.

func PrintPlainTable

func PrintPlainTable(colNames []string, rows [][]string)

PrintPlainTable prints a properly aligned table for non-TTY output. Shows full content without truncation.

func RunTableTUI

func RunTableTUI(title string, columns []string, rows [][]string) error

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.

func Truncate

func Truncate(s string, width int) string

Truncate shortens a string to fit width, adding "..." if needed.

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.

Jump to

Keyboard shortcuts

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