Documentation
¶
Overview ¶
Package table provides static table rendering for CLI output.
This package is designed for non-interactive command output (like kubectl get, ls -l, etc.) and is separate from the interactive Bubble Tea components in the parent tui package.
Example usage:
table := table.New("Name", "Status", "Age")
table.AddRow("service-a", "Running", "2d")
table.AddRow("service-b", "Stopped", "5h")
fmt.Println(table.Render())
Output:
┌───────────┬─────────┬─────┐ │ Name │ Status │ Age │ ├───────────┼─────────┼─────┤ │ service-a │ Running │ 2d │ ├───────────┼─────────┼─────┤ │ service-b │ Stopped │ 5h │ └───────────┴─────────┴─────┘
Index ¶
- Variables
- type BorderStyle
- type Table
- func (t *Table) AddRow(cells ...string)
- func (t *Table) AddRows(rows [][]string)
- func (t *Table) Clear()
- func (t *Table) Print()
- func (t *Table) PrintSimple()
- func (t *Table) Render() string
- func (t *Table) RenderSimple() string
- func (t *Table) SetBorderStyle(style BorderStyle)
- func (t *Table) SetHeaderBold(bold bool)
- func (t *Table) String() string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // BorderStyleRounded uses rounded Unicode box-drawing characters BorderStyleRounded = BorderStyle{ TopLeft: "┌", TopRight: "┐", BottomLeft: "└", BottomRight: "┘", Horizontal: "─", Vertical: "│", Cross: "┼", LeftT: "├", RightT: "┤", TopT: "┬", BottomT: "┴", } // BorderStyleDouble uses double-line box-drawing characters BorderStyleDouble = BorderStyle{ TopLeft: "╔", TopRight: "╗", BottomLeft: "╚", BottomRight: "╝", Horizontal: "═", Vertical: "║", Cross: "╬", LeftT: "╠", RightT: "╣", TopT: "╦", BottomT: "╩", } // BorderStyleASCII uses plain ASCII characters for maximum compatibility BorderStyleASCII = BorderStyle{ TopLeft: "+", TopRight: "+", BottomLeft: "+", BottomRight: "+", Horizontal: "-", Vertical: "|", Cross: "+", LeftT: "+", RightT: "+", TopT: "+", BottomT: "+", } )
Common border styles
Functions ¶
This section is empty.
Types ¶
type BorderStyle ¶
type BorderStyle struct {
TopLeft string
TopRight string
BottomLeft string
BottomRight string
Horizontal string
Vertical string
Cross string
LeftT string
RightT string
TopT string
BottomT string
}
BorderStyle defines the characters used for table borders
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a static table for CLI output
Example ¶
Example test that demonstrates usage
table := New("Name", "Status", "Age")
table.AddRow("service-a", "Running", "2d")
table.AddRow("service-b", "Stopped", "5h")
table.Print()
// Output will show a formatted table
func (*Table) PrintSimple ¶
func (t *Table) PrintSimple()
PrintSimple renders and prints the table in simple mode (no row separators)
func (*Table) RenderSimple ¶
RenderSimple renders the table without row separators (more compact)
func (*Table) SetBorderStyle ¶
func (t *Table) SetBorderStyle(style BorderStyle)
SetBorderStyle sets the border style for the table
func (*Table) SetHeaderBold ¶
SetHeaderBold controls whether headers are rendered in bold