term

package
v0.0.0-...-4ff3f89 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TableConfig

type TableConfig struct {
	MaxLineWidth   int
	MaxColumnWidth int
	// GetTerminalWidth takes precedence over MaxLineWidth if provided.
	GetTerminalWidth TerminalWidthGetter
	// IncludeHeader indicates whether the first line of data is a header.
	IncludeHeader bool
	// JSONTagsAsHeaders indicates whether to use struct `json` tags as the
	// values for the header line. Implies IncludeHeader. Only used with
	// Structs().
	JSONTagsAsHeaders bool
	// TimeAsDiffs causes time.Time fields to be converted to human-readable
	// diffs from the current time.
	TimeAsDiffs bool
	// EmptyCollectionsBlank causes empty slices and maps to appear blank as
	// opposed to "[]" or "map[]".
	EmptyCollectionsBlank bool
}

TableConfig provides configuration for building textual tables.

func (TableConfig) MakeTable

func (c TableConfig) MakeTable(data [][]string) string

MakeTable creates a textual table from the given data, which is presumed to be broken into rows of cells.

func (TableConfig) Structs

func (c TableConfig) Structs(ctx context.Context, structs interface{}) (string, error)

Structs creates a table from a slice of structs.

type TerminalWidthGetter

type TerminalWidthGetter func() int

TerminalWidthGetter is a function which returns the width of the terminal.

func GetTerminalWidthFunc

func GetTerminalWidthFunc(defaultWidth int) TerminalWidthGetter

GetTerminalWidthFunc returns a TerminalWidthGetter which finds the width of the terminal or returns the given default if not running in a terminal.

Jump to

Keyboard shortcuts

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