Documentation ¶
Overview ¶
Package termui is a wrapper to enable disabling input echo and other terminal handling.
Index ¶
- Constants
- func Decolorize(message string) string
- func HeaderColor(s string) string
- func PrintAndExit(ui *UI, err error)
- func PrintWarning(ui *UI, err error)
- func TableContentHeaderColor(s string) string
- type Error
- type ErrorPrinter
- type Table
- type Transformer
- type UI
- func (u *UI) Print(args ...interface{}) (int, error)
- func (u *UI) Printf(format string, args ...interface{}) (int, error)
- func (u *UI) Println(args ...interface{}) (int, error)
- func (u *UI) Prompt(promptText string, args ...interface{}) string
- func (u *UI) PromptDefault(promptText, defaultValue string, args ...interface{}) string
Constants ¶
const ( // CodeUnknownError is a generic error code for errors without one CodeUnknownError = iota + 1 )
Variables ¶
This section is empty.
Functions ¶
func Decolorize ¶
Decolorize is a function that strips out all colorizing control bytes
func HeaderColor ¶
HeaderColor is the default header color for tables
func PrintAndExit ¶
PrintAndExit prints the error to the ui and exits the program.
func TableContentHeaderColor ¶
TableContentHeaderColor is the default header content color for tables
Types ¶
type ErrorPrinter ¶
type ErrorPrinter struct {
// contains filtered or unexported fields
}
ErrorPrinter can be used to stop repetitive calls to the global like calls which all take a terminal.UI
func NewErrorPrinter ¶
func NewErrorPrinter(ui *UI) *ErrorPrinter
NewErrorPrinter returns an error printer.
func (ErrorPrinter) PrintAndExit ¶
func (e ErrorPrinter) PrintAndExit(err error)
PrintAndExit prints the error to the UI and exits.
func (ErrorPrinter) PrintWarning ¶
func (e ErrorPrinter) PrintWarning(err error)
PrintWarning prints the error as a warning.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table remembers headers, added rows, column widths, and a number of other things and later formats and prints these things.
func NewTable ¶
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) NoHeaders ¶
func (t *Table) NoHeaders()
NoHeaders disables the printing of the header row for the specified table.
func (*Table) PrintTo ¶
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 datastructures.
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.
type Transformer ¶
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 ¶
UI is an abstraction around a terminal with various helper functions to write to it.
func New ¶
New creates a terminal UI which writes to output, reads from input and can be used to read passwords safely.
func (*UI) PromptDefault ¶
PromptDefault gets a line of input and provides a default if nothing is given.
Directories ¶
Path | Synopsis |
---|---|
Package sigint provides a Handler that calls exit handlers when the process has been interrupted by sigint (a ctrl-c typically).
|
Package sigint provides a Handler that calls exit handlers when the process has been interrupted by sigint (a ctrl-c typically). |
fakes
Package fakes is was generated by counterfeiter.
|
Package fakes is was generated by counterfeiter. |