table

package module
v0.0.0-...-9e4d6a9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 11 Imported by: 0

README

terminal-table

A golang library for building Tables in Terminal applications

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Output    = colorable.NewColorableStdout()
	ErrOutput = colorable.NewColorableStderr()

	TerminalSupportsColors = isTerminal()
	UserAskedForColors     = ""
)

Functions

func AdvisoryColor

func AdvisoryColor(message string) string

func Colorize

func Colorize(message string, color *color.Color) string

func ColorsEnabled

func ColorsEnabled() bool

func CommandColor

func CommandColor(message string) string

func CrashedColor

func CrashedColor(message string) string

func Decolorize

func Decolorize(message string) string

func EntityNameColor

func EntityNameColor(message string) string

func FailureColor

func FailureColor(message string) string

func HeaderColor

func HeaderColor(message string) string

func InitColorSupport

func InitColorSupport()

func LogAppHeaderColor

func LogAppHeaderColor(message string) string

func LogHealthHeaderColor

func LogHealthHeaderColor(message string) string

func LogStderrColor

func LogStderrColor(message string) string

func LogStdoutColor

func LogStdoutColor(message string) string

func LogSysHeaderColor

func LogSysHeaderColor(message string) string

func PromptColor

func PromptColor(message string) string

func StoppedColor

func StoppedColor(message string) string

func SuccessColor

func SuccessColor(message string) string

func TableContentHeaderColor

func TableContentHeaderColor(message string) string

func WarningColor

func WarningColor(message string) string

Types

type KeyValueTable

type KeyValueTable struct {
	*TerminalTable
}

func (*KeyValueTable) MarshalJSON

func (t *KeyValueTable) MarshalJSON() ([]byte, error)

type Table

type Table interface {
	Add(row ...string)
	AddNestedTable(row ...interface{})
	Print()
	PrintJson()
	String() string
	SetFormat(outputFormat string)
	SetOutput(writer io.Writer)
}

func NewTable

func NewTable(headers []string) Table

type TerminalTable

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

func (*TerminalTable) Add

func (t *TerminalTable) Add(row ...string)

func (*TerminalTable) AddNestedTable

func (t *TerminalTable) AddNestedTable(row ...interface{})

Used to convert a Row that has a table in it to a string row. I couldn't jsut change the Add function to be Add(row ...interface{}) because it would break users adding rows like in the TestEllipsisTable() unit test

func (*TerminalTable) MarshalJSON

func (t *TerminalTable) MarshalJSON() ([]byte, error)

func (*TerminalTable) Print

func (t *TerminalTable) Print()

func (*TerminalTable) PrintJson

func (t *TerminalTable) PrintJson()

Prints out a nicely/human formatted Json string instead of a table structure

func (*TerminalTable) PrintKeyValueJson

func (t *TerminalTable) PrintKeyValueJson()

func (*TerminalTable) SetFormat

func (t *TerminalTable) SetFormat(outFormat string)

func (*TerminalTable) SetOutput

func (t *TerminalTable) SetOutput(writer io.Writer)

func (*TerminalTable) String

func (t *TerminalTable) String() string

Jump to

Keyboard shortcuts

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