table

package
v3.0.33 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment int
const (
	Auto Alignment = iota
	Left
	Center
	Right
)

type Color

type Color uint16
const (
	None Color = iota
	Black
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)
const (
	Bold      Color = 0x0100
	Underline Color = 0x0200
	Inverse   Color = 0x0400
)

type Formatter

type Formatter interface {
	Format() (string, Alignment, Color)
}

Formatter interface converts internal format to string

type Kind

type Kind uint

Kind represents supported kinds of data

const (
	String Kind = iota
	Float
	Int
	Uint
	Bool
	Time
	Duration
	Nil
)

func (Kind) String

func (k Kind) String() string

type Option

type Option func(*Table)

func WithFooter

func WithFooter(value bool) Option

func WithHeader

func WithHeader(value bool) Option

WithHeader option can be supplied to indicate the presence of a header when using ReadCSV or supplied otherwise to indicate whether the header should be rendered

func WithMergeCells

func WithMergeCells() Option

func WithOffsetLimit

func WithOffsetLimit(offset, limit uint) Option

type Table

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

Table represents a data table with a header & footer

func New

func New(opts ...Option) *Table

New creates an empty table

func ReadCSV

func ReadCSV(r io.Reader, opts ...Option) (*Table, error)

ReadCSV creates a table from a CSV file optionally with a header

func (*Table) Add

func (t *Table) Add(row map[string]interface{})

Add a record from a map into the table, adding new columns as necessary

func (*Table) Append

func (t *Table) Append(row ...interface{})

Append a row of data into the table

func (*Table) Render

func (t *Table) Render(w io.Writer, opts ...Option)

Render table as ASCII to io.Writer Options WithHeader, WithMergeCells and WithOffsetLimit will affect the rendering of the table

func (*Table) RenderCSV

func (t *Table) RenderCSV(w io.Writer, opts ...Option)

RenderCSV renders a table as CSV. Options WithHeader and WithOffsetLimit will affect the rendering of the table

func (*Table) SetHeader

func (t *Table) SetHeader(r ...interface{})

type Types

type Types map[Kind]bool

Types represents possible kinds for a value

func (Types) Del

func (t Types) Del(k Kind)

func (Types) Get

func (t Types) Get(k Kind) bool

func (Types) Kind

func (t Types) Kind() Kind

Kind returns the most likely kind of data for this value

func (Types) Kinds

func (t Types) Kinds() []Kind

func (Types) Parse

func (t Types) Parse(v interface{})

func (Types) Set

func (t Types) Set(k Kind)

Jump to

Keyboard shortcuts

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