ui

package
v0.32.12 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK         = "ok"
	StatusError      = "error"
	StatusWarn       = "warn"
	StatusInProgress = "in_progress"
	StatusInfo       = "info"
)

Variables

View Source
var (
	ColorTrace        = color.New(color.FgMagenta, color.Bold)
	ColorDebug        = color.New(color.FgWhite, color.Faint)
	ColorHeader       = color.New(color.Bold)
	ColorInfo         = color.New()
	ColorProgress     = color.New(color.FgCyan)
	ColorProgressBold = color.New(color.FgCyan, color.Bold)
	ColorError        = color.New(color.FgRed)
	ColorErrorBold    = color.New(color.FgRed, color.Bold)
	ColorSuccess      = color.New(color.FgGreen)
	ColorSuccessBold  = color.New(color.FgGreen, color.Bold)
	ColorWarning      = color.New(color.FgYellow)
	ColorWarningBold  = color.New(color.FgYellow, color.Bold)
	ColorUnderline    = color.New(color.Underline)
)

Functions

func Colorize

func Colorize(c *color.Color, noColor bool, msg string, values ...interface{}) string

func ColorizedNoLogOutput

func ColorizedNoLogOutput(c *color.Color, msg string, values ...interface{})

func ColorizedOutput

func ColorizedOutput(c *color.Color, msg string, values ...interface{})

ColorizedOutput outputs a colored message directly to the terminal. The remaining arguments should be interpolations for the format string.

func DoProgress

func DoProgress() bool

func IsTerminal

func IsTerminal() bool
func Link(text string, url string) string

func SleepBeforeError

func SleepBeforeError(ctx context.Context)

Types

type Progress

type Progress interface {
	// Add adds an additional bar to the progress
	Add(id, displayName, message string, total int64)

	// Update bars status, message and amount
	Update(id, status, msg string, amount int)

	// Increment the progress by given amount
	Increment(id string, amount int)

	// AttachReader to a progress so when an io is read the bar will update as well
	AttachReader(id string, data io.Reader) io.Reader

	// Wait for all progress bars to finish
	Wait()

	// MarkAllDone marks all progress bars as done
	MarkAllDone()
}

Progress is used to provide an updating progress to the user. The progress usually has one or more bars

type ProgressUpdateFunc

type ProgressUpdateFunc func(io.Reader, int64) io.Reader

func CreateProgressUpdater

func CreateProgressUpdater(progress Progress, displayName string) ProgressUpdateFunc

CreateProgressUpdater creates a progress update callback method for periodic updates.

type Table

type Table interface {
	// SetHeaders defines table headers
	SetHeaders(...string)

	// Append adds rows to the table
	Append(...interface{})

	// Render does the actual render of the table
	Render()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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