columns

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F

func F(v any) string

func HumanizeDuration

func HumanizeDuration(d time.Duration) string

Types

type Writer

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

func New

func New(heading string, a ...any) *Writer

func (*Writer) AddMapInts

func (w *Writer) AddMapInts(data map[string]int, sortValues bool, reverse bool)

AddMapInts adds data with each key being a column title and value what follows the :. Optionally sorts by value

func (*Writer) AddMapIntsAsValue

func (w *Writer) AddMapIntsAsValue(t string, data map[string]int, sortValues bool, reverse bool)

AddMapIntsAsValue adds a row with title t and the data as value. Optionally sorts by value.

func (*Writer) AddMapStrings

func (w *Writer) AddMapStrings(data map[string]string)

AddMapStrings adds data with each key being a column title and value what follows the :

func (*Writer) AddMapStringsAsValue

func (w *Writer) AddMapStringsAsValue(t string, data map[string]string)

AddMapStringsAsValue adds a row with title t and the data as value, over multiple lines and correctly justified

func (*Writer) AddRow

func (w *Writer) AddRow(t string, v any)

AddRow adds a row, v will be formatted if time.Time, time.Duration, []string, floats, ints and uints

func (*Writer) AddRowIf

func (w *Writer) AddRowIf(t string, v any, condition bool)

AddRowIf adds a row if the condition is true

func (*Writer) AddRowIfNotEmpty

func (w *Writer) AddRowIfNotEmpty(t string, v string)

AddRowIfNotEmpty adds a row if v is not an empty string

func (*Writer) AddRowf

func (w *Writer) AddRowf(t string, format string, a ...any)

AddRowf adds a row with printf like behavior on the value, no auto formatting of values will be done like in AddRow()

func (*Writer) AddSectionTitle

func (w *Writer) AddSectionTitle(format string, a ...any)

AddSectionTitle adds a new section

func (*Writer) Frender

func (w *Writer) Frender(o io.Writer) error

Frender renders to the writer 0

func (*Writer) Indent

func (w *Writer) Indent(width int)

Indent results in all following text to be indented this many spaces. When called it sets that value, zero resets to no indent

func (*Writer) Println

func (w *Writer) Println(msg ...string)

Println Adds a line to the report rendered outside of columnar layout

func (*Writer) Render

func (w *Writer) Render() (string, error)

Render produce the result as a string

func (*Writer) SetColorScheme

func (w *Writer) SetColorScheme(s string)

SetColorScheme sets a color schema to use. One of yellow, blue, cyan, green, magenta or red - rest treated as no color

func (*Writer) SetHeading

func (w *Writer) SetHeading(format string, a ...any)

SetHeading sets the initial heading

func (*Writer) SetSeparator

func (w *Writer) SetSeparator(seq string)

SetSeparator sets the separator to use after headings, defaults to :

Jump to

Keyboard shortcuts

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