Links

Table

The table printer can be used to display structured data

Basic Usage

pterm.DefaultTable.WithData(pterm.TableData{
{"Paul", "Dean", "[email protected]"},
{"Callie", "Mckay", "[email protected]"},
{"Libby", "Camacho", "[email protected]"},
}).Render()

Options

Name
Type
Description
Style
*Style
Style of the table
HasHeader
bool
Sets if the table has a headline
HeaderStyle
*Style
Style of the table headline
HeaderRowSeparator
string
Row separator in the table headline
HeaderRowSeparatorStyle
*Style
Style of the headline row separator
Separator
string
Character which is used to separate columns
SeparatorStyle
*Style
Style for the separator
RowSeparator
string
Character which is used to separate rows
RowSeparatorStyle
*Style
Style for the row separator
Data
TableData
The table content
Boxed
bool
Sets if the table should be printed with a border box
LeftAlignment
bool
Sets if the text should be aligned to the left
RightAlignment
bool
Sets if the text should be aligned to the right
Writer
io.Writer
Custom output writer

Using Options

Methods

This printer implements the RenderablePrinter interface.
Method
Description
Render()
Prints to the terminal or uses the specified Writer
Srender()
Returns the rendered string

Full Specification

pkg.go.dev contains the full specification for this printer and more technical descriptions.
Last modified 11mo ago