Documentation ¶
Index ¶
- func New(writer io.Writer, valueList []interface{}, configurer func(*tablewriter.Table)) *tablewriter.Table
- func NewTabWriter(writer io.Writer, header []string) *tablewriter.Table
- func Print(writer io.Writer, valueList []interface{})
- type ColumnAttributes
- type ColumnValueFunc
- type CommonColumnsFunc
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(writer io.Writer, valueList []interface{}, configurer func(*tablewriter.Table)) *tablewriter.Table
New creates a tablewriter.Table and allows customizing the table.
Each element should be a simple struct (not pointer) with a number of fields. Each field corresponds to a column in the table, the field must have json tag. The tag name is the column name in the table header.
For example: ```
type tableStruct struct { PartitionCount int `json:"partition_count"` TableName string `json:"name"` } var tables []tableStruct ... tabular.Print(tables)
```
func NewTabWriter ¶
func NewTabWriter(writer io.Writer, header []string) *tablewriter.Table
Types ¶
type ColumnAttributes ¶
type ColumnAttributes struct { Name string Attrs map[string]string // contains filtered or unexported fields }
ColumnAttributes is the
type ColumnValueFunc ¶
type ColumnValueFunc func(col *ColumnAttributes, rowData interface{}) interface{}
ColumnValueFunc takes the column value from a user record.
type CommonColumnsFunc ¶
type CommonColumnsFunc func(rowData interface{}) []string
CommonColumnsFunc returns a list of common columns.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template receives a yaml template for printing the tabular contents. A template must contain one or more sections, each is displayed as a table. A sections could contain multiple keys, each represents as the table column. Template iterates all the items in every section, one item acts as a row in the table.
func NewTemplate ¶
NewTemplate parses the given template.
func (*Template) SetColumnValueFunc ¶
func (t *Template) SetColumnValueFunc(f ColumnValueFunc)
SetColumnValueFunc configures ColumnValueFunc
func (*Template) SetCommonColumns ¶
func (t *Template) SetCommonColumns(columnNames []string, f CommonColumnsFunc)
SetCommonColumns sets the columns that are exactly the same among sections. This is a conveninence util to prevent repeatedly declaring the column for each section.