table

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT, + 1 more Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TitleStyle can be used to format a string; suitable for titles
	TitleStyle = globals.TitleStyle

	// PrimaryTextStyle can be used to format a string; suitable for emphasis
	PrimaryTextStyle = globals.PrimaryTextStyle

	// CTATextStyle can be used to format a string; important text
	CTATextStyle = globals.CTATextStyle
)

Functions

This section is empty.

Types

type Column

type Column struct {
	Title           string
	CellTransformer func(data interface{}) string
	ColumnStyle     func(string) string
}

Column describes a standard table's column

type Row

type Row struct {
	Value interface{}
}

Row describes a value that will represent a row in our table

type Table

type Table struct {
	Columns []*Column
	// contains filtered or unexported fields
}

Table describes a set of related data

func New

func New(columns []*Column) *Table

New return a new Table given columns

Usage:

table := table.New([]*table.Column{
  {
    Title: "Source",
    ColumnStyle: table.PrimaryTextStyle,	            // Make each row blue
    CellTransformer: func(data interface{}) string {
      event, _ := data.(types.Event)
      return event.Entity.Name                         // Called for each row
    }
  },
  // ...
})

table.Render(data)

func (*Table) Render

func (t *Table) Render(io io.Writer, results interface{})

Render renders table to STDOUT given row values

Jump to

Keyboard shortcuts

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