ui

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: ISC Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Black   = Style{FgBlack}
	Red     = Style{FgRed}
	Green   = Style{FgGreen}
	Yellow  = Style{FgYellow}
	Blue    = Style{FgBlue}
	Magenta = Style{FgMagenta}
	Cyan    = Style{FgCyan}
	White   = Style{FgWhite}
)

Functions

This section is empty.

Types

type ANSICode

type ANSICode int
const (
	Reset ANSICode = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)
const (
	FgBlack ANSICode = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)
const (
	BgBlack ANSICode = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

type Level

type Level int

Level represents the verbosity level.

const (
	// Trace shows all messages.
	Trace Level = iota
	// Debug shows Debug, Info, Warn, and Error messages.
	Debug
	// Info shows Info, Warn, and Error messages.
	Info
	// Warn shows Warn and Error messages.
	Warn
	// Error shows only Error messages.
	Error
	// None does not show any messages.
	None
)

type Style

type Style []ANSICode

type UI

type UI interface {
	// Output method independent of the verbosity level
	Printf(format string, a ...interface{})

	// Leveled output methods
	GetLevel() Level
	SetLevel(l Level)
	Tracef(s Style, format string, a ...interface{})
	Debugf(s Style, format string, a ...interface{})
	Infof(s Style, format string, a ...interface{})
	Warnf(s Style, format string, a ...interface{})
	Errorf(s Style, format string, a ...interface{})
}

UI is the interface for interacting with users in command-line applications.

func New

func New(level Level) UI

New creates a new user interface. This is a concurrent-safe UI and can be used across multiple Go routines.

func NewNop

func NewNop() UI

NewNop creates a nop user interface for testing purposes.

Jump to

Keyboard shortcuts

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