asciitable

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 7 Imported by: 2

README

go-asciitable

Draw ASCII tables in console. Bloody alpha at the edge of being unusable, your PRs are welcome.

Usage

As simple as that (as of now):

table := asciitable.NewSimpleTable()
table.Header("Name", "Description")
table.AddRow("Strawberry", "Fruit in yours granma's garten")
table.AddRow("Raspberry", "Useless hardware you anyway will buy")
table.AddRow("Perl", "Also language")
fmt.Println(table.Render())

Result:

+----------+------------------------------------+
|Name      |Description                         |
+----------+------------------------------------+
|Strawberry|Fruit in yours granma's garten      |
+----------+------------------------------------+
|Raspberry |Useless hardware you anyway will buy|
+----------+------------------------------------+
|Perl      |Also language                       |
+----------+------------------------------------+

Documentation

Index

Constants

View Source
const (
	ALIGN_LEFT = iota
	ALIGN_CENTER
	ALIGN_RIGHT
	BORDER_SINGLE_THIN
	BORDER_SINGLE_THICK
	BORDER_DOUBLE
	BORDER_NONE
)

Configuration of the table.

Variables

This section is empty.

Functions

func GetTerminalSize

func GetTerminalSize() (int, int)

func NewBorderStyle

func NewBorderStyle(outer int, inner int) *borderStyle

func NewSimpleTable

func NewSimpleTable(data *TableData, style *borderStyle) *simpleTable

NewSimpleTable object constructor

Types

type TableData

type TableData struct {
	// contains filtered or unexported fields
}

func NewTableData

func NewTableData() *TableData

NewTableData object constructor

func (*TableData) AddRow

func (tableData *TableData) AddRow(row ...interface{}) *TableData

func (*TableData) GetColsNum

func (tableData *TableData) GetColsNum() int

Get number of columns in the table

func (*TableData) GetData

func (tableData *TableData) GetData() *[][]string

Get raw table data

func (*TableData) GetHeader

func (tableData *TableData) GetHeader() *[]string

Get table header data

func (*TableData) GetRowsNum

func (tableData *TableData) GetRowsNum() int

Get number of rows in the table

func (*TableData) SetData

func (tableData *TableData) SetData(data [][]interface{}) *TableData

func (*TableData) SetHeader

func (tableData *TableData) SetHeader(titles ...string) *TableData

Set Header of the table. Each string represents a column name. Previous data is wept away.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL