table

package
v5.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: Apache-2.0 Imports: 12 Imported by: 180

Documentation

Index

Constants

View Source
const UNKNOWN_HEADER_MAPPING rune = '_'

Variables

This section is empty.

Functions

func KeyifyHeader

func KeyifyHeader(header string) string

Types

type ColumnSort

type ColumnSort struct {
	Column int
	Asc    bool
}

type EmptyValue

type EmptyValue struct{}

func (EmptyValue) Compare

func (t EmptyValue) Compare(Value) int

func (EmptyValue) String

func (t EmptyValue) String() string

func (EmptyValue) Value

func (t EmptyValue) Value() Value
type Header struct {
	Key    string
	Title  string
	Hidden bool
}

func NewHeader

func NewHeader(title string) Header

type Section

type Section struct {
	FirstColumn Value
	Rows        [][]Value
}

type Sorting

type Sorting struct {
	SortBy []ColumnSort
	Rows   [][]Value
}

func (Sorting) Len

func (s Sorting) Len() int

func (Sorting) Less

func (s Sorting) Less(i, j int) bool

func (Sorting) Swap

func (s Sorting) Swap(i, j int)

type Table

type Table struct {
	Title   string
	Content string

	Header []Header

	SortBy []ColumnSort

	// Either sections or rows should be provided
	Sections []Section
	Rows     [][]Value

	Notes []string

	// Formatting
	HeaderFormatFunc func(string, ...interface{}) string
	DataOnly         bool
	FillFirstColumn  bool
	BackgroundStr    string
	BorderStr        string
	Transpose        bool
}

func (Table) AddColumn

func (t Table) AddColumn(header string, values []Value) Table

func (Table) AsRows

func (t Table) AsRows() [][]Value

func (Table) Print

func (t Table) Print(w io.Writer) error

func (*Table) SetColumnVisibility

func (t *Table) SetColumnVisibility(headers []Header) error

type Value

type Value interface {
	Value() Value
	String() string
	Compare(Value) int
}

type ValueBool

type ValueBool struct {
	B bool
}

func NewValueBool

func NewValueBool(b bool) ValueBool

func (ValueBool) Compare

func (t ValueBool) Compare(other Value) int

func (ValueBool) String

func (t ValueBool) String() string

func (ValueBool) Value

func (t ValueBool) Value() Value

type ValueBytes

type ValueBytes struct {
	I uint64
}

func NewValueBytes

func NewValueBytes(i uint64) ValueBytes

func NewValueMegaBytes added in v0.0.53

func NewValueMegaBytes(i uint64) ValueBytes

func (ValueBytes) Compare

func (t ValueBytes) Compare(other Value) int

func (ValueBytes) String

func (t ValueBytes) String() string

func (ValueBytes) Value

func (t ValueBytes) Value() Value

type ValueError

type ValueError struct {
	E error
}

func NewValueError

func NewValueError(e error) ValueError

func (ValueError) Compare

func (t ValueError) Compare(other Value) int

func (ValueError) String

func (t ValueError) String() string

func (ValueError) Value

func (t ValueError) Value() Value

type ValueFmt

type ValueFmt struct {
	V     Value
	Error bool
	Func  func(string, ...interface{})