Documentation
¶
Overview ¶
Package ui provides user interface functionalities.
Index ¶
Constants ¶
const DurationThreshold = 1 * time.Second
DurationThreshold is a threshold to show event time only if duration is higher than this threshold. b/294443556
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration formats duration in "X.XXs", "XmXX.XXs" or "XhXmXX.XXs".
func StripANSIEscapeCodes ¶
StripANSIEscapeCodes strips ANSI escape codes.
Types ¶
type LogUI ¶
type LogUI struct{}
LogUI is a log-based UI.
func (LogUI) NewSpinner ¶
func (LogUI) NewSpinner() spinner
NewSpinner returns an implementation of ui.spinner.
func (LogUI) PrintLines ¶
PrintLines implements the ui.ui interface. Because a log-based UI cannot support erasing previous lines, msgs will be printed as-is.
type SGRCode ¶
type SGRCode int
https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
type TermUI ¶
type TermUI struct {
// contains filtered or unexported fields
}
TermUI is a terminal-based UI.
func (TermUI) NewSpinner ¶
func (TermUI) NewSpinner() spinner
NewSpinner returns a terminal-based spinner.
func (*TermUI) PrintLines ¶
PrintLines implements the ui.ui interface. msg not including \n will fit on one terminal line, by eliding middle for long msg. msg including \n will print as is. If msgs starts with \n, it will print from the current line. Otherwise, it will replace the last N lines, where N is number of msgs that don't start with \n.
type UI ¶
type UI interface { // PrintLines prints message lines. // If msgs starts with \n, it will print from the current line. // Otherwise, it will replaces the last N lines, where N is len(msgs). PrintLines(msgs ...string) // NewSpinner returns a new spinner. NewSpinner() spinner }
UI is a user interface.
var Default UI
Default holds the default UI interface. Making changes to this variable after init is undefined behavior. UI implementations are currently not expected to handle being changed.