terminal

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TerminalSupportsColors = isTerminal()
	UserAskedForColors     = ""
)

Functions

func AdvisoryColor

func AdvisoryColor(message string) string

func Colorize

func Colorize(message string, textColor color.Attribute) string

func ColorizeBold

func ColorizeBold(message string, textColor color.Attribute) string

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 NotLoggedInText

func NotLoggedInText() 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 ColoringFunction

type ColoringFunction func(value string, row int, col int) string

type Printer

type Printer interface {
	Print(a ...interface{}) (n int, err error)
	Printf(format string, a ...interface{}) (n int, err error)
	Println(a ...interface{}) (n int, err error)
}

type Table

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

PrintableTable is an implementation of the Table interface. It remembers the headers, the added rows, the column widths, and a number of other things.

func NewTable

func NewTable(headers []string) *Table

NewTable is the constructor function creating a new printable table from a list of headers. The table is also connected to a UI, which is where it will print itself to on demand.

func (*Table) Add

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

Add extends the table by another row.

func (*Table) NoHeaders

func (t *Table) NoHeaders()

NoHeaders disables the printing of the header row for the specified table.

func (*Table) PrintTo

func (t *Table) PrintTo(result io.Writer) error

PrintTo is the core functionality for printing the table, placing the formatted table into the writer given to it as argument. The exported Print() is just a wrapper around this which redirects the result into CF data structures. Once a table has been printed onto a Writer, it cannot be printed again.

func (*Table) SetTransformer

func (t *Table) SetTransformer(columnIndex int, tr Transformer)

SetTransformer specifies a string transformer to apply to the content of the given column in the specified table.

func (*Table) Transform

func (t *Table) Transform(column int, s string) string

Transform makes a PrintableTable an implementation of rowTransformer. It performs the per-column transformation for table content, as specified during construction and/or overridden by the user of the table, see SetTransformer.

type TeePrinter

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

func NewTeePrinter

func NewTeePrinter(w io.Writer) *TeePrinter

func (*TeePrinter) DisableTerminalOutput

func (t *TeePrinter) DisableTerminalOutput(disable bool)

func (*TeePrinter) Print

func (t *TeePrinter) Print(values ...interface{}) (int, error)

func (*TeePrinter) Printf

func (t *TeePrinter) Printf(format string, a ...interface{}) (int, error)

func (*TeePrinter) Println

func (t *TeePrinter) Println(values ...interface{}) (int, error)

func (*TeePrinter) SetOutputBucket

func (t *TeePrinter) SetOutputBucket(bucket io.Writer)

type Transformer

type Transformer func(s string) string

Transformer is the type of functions used to modify the content of a table cell for actual display. For multi-line content of a cell the transformation is applied to each individual line.

type UI

type UI interface {
	PrintPaginator(rows []string, err error)
	Say(message string, args ...interface{})

	// ProgressReader
	PrintCapturingNoOutput(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Ask(prompt string) (answer string)
	AskForPassword(prompt string) (answer string)
	Confirm(message string) bool
	ConfirmDelete(modelType, modelName string) bool
	ConfirmDeleteWithAssociations(modelType, modelName string) bool
	Ok()
	Failed(message string, args ...interface{})
	ShowConfiguration(coreconfig.Reader) error
	LoadingIndication()
	Table(headers []string) *UITable
	NotifyUpdateIfNeeded(coreconfig.Reader)

	Writer() io.Writer
}

func NewUI

func NewUI(r io.Reader, w io.Writer, printer Printer, logger trace.Printer) UI

type UITable

type UITable struct {
	UI    UI
	Table *Table
}

func (*UITable) Add

func (u *UITable) Add(row ...string)

func (*UITable) Print

func (u *UITable) Print() error

Print formats the table and then prints it to the UI specified at the time of the construction. Afterwards the table is cleared, becoming ready for another round of rows and printing.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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