A simple library to create nested tables in the terminal.
go get github.com/data-preservation-programs/table@latesttype Person struct {
ID int
Name string
AverageScore int `table:"header:Average Score"`
Grade string `table:"color:96;headerColor:96,4"`
Scores []Score `table:"headerColor:34,4;expand"`
}
type Score struct {
Subject string
Score float32
GradedAt time.Time `table:"header:Graded At;format:2006-01-02"`
}
func main () {
fmt.Println(table.New().Render([]Person{...}))
}headerThe header string to use for the column.headerColorThe color to use for the header. The color is specified as a comma separated list of color codes. Check available values herecolorThe color to use for the column. The color is specified as a comma separated list of color codes. Check available values hereformatThe format to use for the column. Fortime.Time, the format is specified as a Go time layout. For all other types, the format is specified as a Go format string.verboseIf set to true, the column will be displayed only when the verbose is set to true in theTable.expandIf set to true, the column will be expanded to a sub table. The column needs to be a slice/instance/pointer to a struct.-If specified, the column will be hidden.
Table.WithTabSet the tab string that is appended to the sub-tables.Table.WithVerboseColumns withverbosetag is only displayed when the verbose is set to true.Table.WithPaddingSizeSet the padding size for each column which is the minimum padding between the columns.Table.WithHeaderRowColorOverrides the default header row color.Table.WithFirstColumnColorOverrides the default first column color.
