Documentation
¶
Overview ¶
Package table implements utilities for rendering tables and managing table data.
The template funcs registered by this package are:
- Table [ string | *Format ]
- EndTable
- Headers <[]string>
- Footers <[]string>
- Row
- Cell <string>
The Table function takes an optional argument which is the name of a format or a value to use for formatting the table. To conclude the table, use EndTable. Headers/Footers appears optionally to denote the names of the headers. Row must be used to group together cells. The content of each cell is passed to the Cell function.
"Default" and "Unformatted" are the built-in Formats
A viable table looks like:
{{- Table "Unformatted" -}}
{{- Headers "First" "Last" }}
{{- Row -}}
{{- Cell "George" -}}
{{- Cell "Burdell" -}}
{{- EndTable -}}`
Additional formats can be registered using the RegisterTableFormat action.
When you want to display tabular data in the CLI, you can use the RegisterTable function to give the table a name and specify
Index ¶
Constants ¶
const ( // UseTablesInHelpTemplate causes tables to be used in the help template UseTablesInHelpTemplate = Feature(1 << iota) // TemplateFuncs enables the template funcs feature, which provides template funcs // for colors and styles TemplateFuncs // AllFeatures enables all of the features. This is the default AllFeatures = -1 )
const ( // Unformatted is the table format associated with a table with no boxes or alignments Unformatted = "Unformatted" // Porcelain is a table that only uses tabs to separate columns Porcelain = "Porcelain" )
const ( AlignDefault Alignment = tablewriter.ALIGN_DEFAULT AlignCenter = tablewriter.ALIGN_CENTER AlignRight = tablewriter.ALIGN_RIGHT AlignLeft = tablewriter.ALIGN_LEFT )
Align constants
Variables ¶
This section is empty.
Functions ¶
func RegisterHelpTemplates ¶
RegisterHelpTemplates causes various templates used in the default help template to be overridden with ones that use tables
func RegisterTemplateFuncs ¶
RegisterTemplateFuncs provides the template functions described in the package overview:
- Table
- EndTable
- Headers
- Footers
- Row, and
- Cell
Types ¶
type Format ¶
type Format struct {
Alignment Alignment
AutoFormatHeaders bool
AutoWrapText bool
Border bool
CenterSeparator string
ColumnSeparator string
ColWidth int
HeaderAlignment Alignment
HeaderLine bool
NoWhiteSpace bool
RowLine bool
RowSeparator string
TablePadding string
TopLeftSeparator string
TopCenterSeparator string
TopRightSeparator string
CenterLeftSeparator string
CenterRightSeparator string
BottomLeftSeparator string
BottomCenterSeparator string
BottomRightSeparator string
}
Format defines the optional format for tables