Documentation ¶
Index ¶
- Variables
- type BorderStyle
- type Cell
- type DividerStyle
- type OpFunc
- type Options
- type Row
- type Style
- type Table
- func (t *Table) AddHead(names ...string) *Table
- func (t *Table) AddRow(cols ...any)
- func (t *Table) Format()
- func (t *Table) Print()
- func (t *Table) Println()
- func (t *Table) Render()
- func (t *Table) SetRows(rs any) *Table
- func (t *Table) String() string
- func (t *Table) WithOptions(fns ...OpFunc) *Table
- func (t *Table) WriteTo(w io.Writer) (int64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // StyleDefault - MySql-like table style: StyleDefault = Style{ HeadColor: "", RowColor: "", Border: BorderStyle{ TopLeft: '+', Top: '-', TopIntersect: '+', TopRight: '+', Right: '|', Cell: '|', BottomRight: '+', Bottom: '-', BottomLeft: '+', BottomIntersect: '+', }, Divider: DividerStyle{}, } StyleSimple = Style{} StyleMarkdown = Style{} )
Functions ¶
This section is empty.
Types ¶
type BorderStyle ¶ added in v3.1.1
type BorderStyle struct {
TopLeft, Top, TopIntersect, TopRight rune
Right, Center, Cell, Left rune
BottomRight, Bottom, BottomIntersect, BottomLeft rune
}
BorderStyle for table
type Cell ¶ added in v3.1.1
type Cell struct { // Width is the width of the cell Width int // Wrap when true wraps the contents of the cell when the length exceeds the width Wrap bool // Align when true aligns contents to the right Align strutil.PosFlag // Val is the cell data Val any // contains filtered or unexported fields }
Cell represents a column in a row
type DividerStyle ¶ added in v3.1.1
DividerStyle defines table divider style
type Options ¶ added in v3.1.1
type Options struct { TitleStyle string HeaderStyle string BottomBorder []rune Alignment strutil.PosFlag ColMaxWidth int LineNumber bool WrapContent bool // HasBorder show border line HasBorder bool // RowBorder show row border RowBorder bool // HeadBorder show head border HeadBorder bool // WrapBorder wrap border for table WrapBorder bool }
Options struct
type Row ¶ added in v3.1.1
type Row struct { // Cells is the group of cell for the row Cells []*Cell // Separator for table columns Separator rune }
Row represents a row in a table
type Style ¶ added in v3.1.1
type Style struct { Border BorderStyle Divider DividerStyle HeadColor string RowColor string }
Style for table
━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━ # │ pid │ name │ status │ cpu ───┼───────┼─────────────────┼──────────┼────────── 0 │ 992 │ chrome │ Sleeping │ 6.988768 2 │ 13973 │ qemu-system-x86 │ Sleeping │ 4.996551 ━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━ +-----+------------+-----------+--------+-----------------------------+ | # | FIRST NAME | LAST NAME | SALARY | | +-----+------------+-----------+--------+-----------------------------+ | 1 | Arya | Stark | 3000 | | | 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! | | 300 | Tyrion | Lannister | 5000 | | +-----+------------+-----------+--------+-----------------------------+ | | | TOTAL | 10000 | | +-----+------------+-----------+--------+-----------------------------+
type Table ¶
type Table struct { show.Base // use for internal // Title for the table Title string // Heads the table head data Heads []string // Rows table data rows Rows []*Row // contains filtered or unexported fields }
Table a cli Table show
func (*Table) Println ¶ added in v3.1.1
func (t *Table) Println()
Println formatted message with newline
func (*Table) Render ¶ added in v3.1.1
func (t *Table) Render()
Render formatted message with newline
func (*Table) WithOptions ¶ added in v3.1.1
WithOptions for table
Click to show internal directories.
Click to hide internal directories.