Documentation ¶
Overview ¶
Package table is the internal shim for providing table support for laying out content prettily.
All interaction with the dependency which provides terminal-drawn tables should go through this module. This provides a shim, giving us isolation. We know the exact subset of features which we rely upon, and can switch providers. If desired, we can use multiple files with build-tags, to let the dependency be satisfied at build-time.
Package table provides table support for character. This implementation uses tabular for layout.
With the more modern Golang features, this should probably be in /internal/ namespace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AvailableStyles []string
AvailableStyles when non-nil, indicates that we can set style options, and lists those styles. Should be sorted.
var RenderStyle string
RenderStyle represents how the table should be styled.
Functions ¶
Types ¶
type Alignment ¶
type Alignment int
Alignment indicates our table column alignments. We only use per-column alignment and do not pass through any per-cell alignments.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
A Table encapsulates our terminal table object from the dependency.
func (*Table) AddHeaders ¶
func (t *Table) AddHeaders(headers ...interface{})
AddHeaders takes a sequence of header-names for each column, and configures them as the header row.
func (*Table) AddRow ¶
func (t *Table) AddRow(cells ...interface{})
AddRow takes a sequence of cells for one table body row.
func (*Table) AddSeparator ¶
func (t *Table) AddSeparator()
AddSeparator adds one row to the table, as a separator.
func (*Table) AlignColumn ¶
AlignColumn sets the alignment of one column in a given table. It counts columns starting from 1.
func (*Table) Render ¶
Render gives us the full table as a string for display. FIXME: why can't we return an error here?
func (*Table) SetSkipableColumn ¶
SetSkipableColumn sets a column as skipable in some contexts (typically if every entry is empty).