Documentation ¶
Overview ¶
Package pretty provides a utility to print out organized data in a pretty manner.
Table can be used as thus: prettyTable, _ := NewPrettyTable(
NewColumnDef("Name"), NewColumnDef("Type"))
prettyTable.AddRow("Noel", "Human") prettyTable.AddRow("David", "Cyborg") prettyTable.AddRow("Pranava", "Crusher") prettyTable.Print()
Output looks like: +---------+---------+ | Name | Type | +---------+---------+ | Noel | Human | | David | Cyborg | | Pranava | Crusher | +---------+---------+
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnDef ¶
type ColumnDef struct {
// contains filtered or unexported fields
}
ColumnDef is a representation of a column definition with a name and a maximum width. The max width must be > 3, and the name must be shorter than the max width. Errors will happen on instantiation of the table.
func NewColumnDef ¶
NewColumnDef creates a ColumnDef with a name and no maximum width.
func NewColumnDefWithWidth ¶
NewColumnDefWithWidth creates a ColumnDef with a name and maximum width.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table creates formatted tables for human readability.
func NewPrettyTable ¶
NewPrettyTable creates a new Table.
func (*Table) PrettyString ¶
PrettyString creates the pretty string representing this table.
func (*Table) SetRows ¶
SetRows sets the rows of the table, overriding any that might currently be there.
func (*Table) ShowRowCount ¶
ShowRowCount is a configuration, defaulted to false, that can be toggled on to print row count when Print() is called.