Documentation
¶
Index ¶
- func SetIsTTY(isTTY bool)
- func SetNonTTYSeparator(s string)
- func SetTTYSeparator(s string)
- func SetTerminalWidth(width int)
- type TableCell
- type TablePrinter
- func (t *TablePrinter) AddCell(s interface{})
- func (t *TablePrinter) AddCellf(s string, f ...interface{})
- func (t *TablePrinter) AddRow(str ...interface{})
- func (t *TablePrinter) AddRowFunc(f func(int, int) string)
- func (t *TablePrinter) Bytes() []byte
- func (t *TablePrinter) EndRow()
- func (t *TablePrinter) Render() string
- func (t *TablePrinter) Separator() string
- func (t *TablePrinter) SetIsTTY(isTTY bool)
- func (t *TablePrinter) SetNonTTYSeparator(s string)
- func (t *TablePrinter) SetTTYSeparator(s string)
- func (t *TablePrinter) SetTerminalWidth(width int)
- func (t *TablePrinter) String() string
- type TableRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetIsTTY ¶
func SetIsTTY(isTTY bool)
SetIsTTY sets the IsTTY variable which indicates whether terminal output is a TTY or nonTTY
func SetNonTTYSeparator ¶
func SetNonTTYSeparator(s string)
SetNonTTYSeparator sets the separator for the columns in the table for non-ttys
func SetTTYSeparator ¶
func SetTTYSeparator(s string)
SetTTYSeparator sets the separator for the columns in the table for TTYs
func SetTerminalWidth ¶
func SetTerminalWidth(width int)
SetTerminalWidth sets the maximum width for the terminal
Types ¶
type TableCell ¶
type TableCell struct { // Value in the cell Value interface{} // 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 // contains filtered or unexported fields }
type TablePrinter ¶
type TablePrinter struct { // Total number of records. Needed if AddRowFunc is used TotalRows int // Wrap when set to true wraps the contents of the columns when the length exceeds the MaxColWidth Wrap bool // MaxColWidth is the maximum allowed width for cells in the table MaxColWidth int // TTYSeparator is the separator for columns in the table on TTYs. Default is "\t" TTYSeparator string // NonTTYSeparator is the separator for columns in the table on non-TTYs. Default is "\t" NonTTYSeparator string // Rows is the collection of rows in the table Rows []*TableRow // TerminalWidth is the max width of the terminal TerminalWidth int // IsTTY indicates whether output is a TTY or non-TTY IsTTY bool }
TablePrinter represents a decorator that renders the data formatted in a tabular form.
func NewTablePrinter ¶
func NewTablePrinter() *TablePrinter
func (*TablePrinter) AddCell ¶
func (t *TablePrinter) AddCell(s interface{})
func (*TablePrinter) AddCellf ¶
func (t *TablePrinter) AddCellf(s string, f ...interface{})
AddCellf formats according to a format specifier and adds cell to row
func (*TablePrinter) AddRow ¶
func (t *TablePrinter) AddRow(str ...interface{})
func (*TablePrinter) AddRowFunc ¶
func (t *TablePrinter) AddRowFunc(f func(int, int) string)
func (*TablePrinter) Bytes ¶
func (t *TablePrinter) Bytes() []byte
Bytes returns the []byte value of table
func (*TablePrinter) EndRow ¶
func (t *TablePrinter) EndRow()
func (*TablePrinter) Render ¶
func (t *TablePrinter) Render() string
Render builds and returns the string representation of the table
func (*TablePrinter) Separator ¶
func (t *TablePrinter) Separator() string
func (*TablePrinter) SetIsTTY ¶
func (t *TablePrinter) SetIsTTY(isTTY bool)
func (*TablePrinter) SetNonTTYSeparator ¶
func (t *TablePrinter) SetNonTTYSeparator(s string)
func (*TablePrinter) SetTTYSeparator ¶
func (t *TablePrinter) SetTTYSeparator(s string)
func (*TablePrinter) SetTerminalWidth ¶
func (t *TablePrinter) SetTerminalWidth(width int)
func (*TablePrinter) String ¶
func (t *TablePrinter) String() string
String returns the string value of table. Alternative to Render()
Click to show internal directories.
Click to hide internal directories.