ui

package
v0.29.0-rc Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: BSD-3-Clause Imports: 9 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bold added in v0.29.0

func Bold(s string) string

Progress calls Progress on the default UI

func BoldColor added in v0.29.0

func BoldColor(c UIColor, s string) string

func Color added in v0.29.0

func Color(c UIColor, s string) string

func Error added in v0.28.1

func Error(format string, args ...interface{})

Error calls Error on the default UI

func Faint added in v0.29.0

func Faint(s string) string

func Hint

func Hint(str string, noPadding bool, label *string)

Hint calls hint on the default UI

func Info added in v0.28.1

func Info(format string, args ...interface{})

Info calls Info on the default UI

func Init

func Init(preferences *prefs.Preferences)

Init initializes a default global UI, accessible via the package functions.

func Line added in v0.23.0

func Line(format string, a ...interface{})

Line calls Line on the default UI

func LineIndent added in v0.23.0

func LineIndent(indent int, format string, a ...interface{})

LineIndent calls LineIndent on the default UI

func Progress

func Progress(str string)

Progress calls Progress on the default UI

func Warn added in v0.28.1

func Warn(format string, args ...interface{})

Warn calls Warn on the default UI

Types

type UI added in v0.23.0

type UI struct {
	Indent int

	// Cols holds the column width for text wrapping. For the default UI and
	// its children, It is either the width of the  terminal, or defaultCols,
	// minus rightPad.
	Cols int

	// EnableProgress is whether progress events should be displayed
	EnableProgress bool

	// EnableHints is whether hints should be displayed
	EnableHints bool

	// EnableColors is whether formatted text should be colored
	EnableColors bool
}

UI exposes methods for creating a terminal ui

func Child added in v0.23.0

func Child(indent int) *UI

Child calls Child on the default UI

func (*UI) Bold added in v0.29.0

func (u *UI) Bold(s string) string

func (*UI) BoldColor added in v0.29.0

func (u *UI) BoldColor(c UIColor, s string) string

func (*UI) Child added in v0.23.0

func (u *UI) Child(indent int) *UI

Child returns a new UI, with settings from the receiver UI, and Indent increased by the provided value.

func (*UI) Color added in v0.29.0

func (u *UI) Color(c UIColor, s string) string

func (*UI) Error added in v0.28.1

func (u *UI) Error(format string, args ...interface{})

Error handles outputting error information to the user such as the fact they couldn't log in due to an error.

The error is printed out to stderr if stdout is not attached to a termainl

func (*UI) Faint added in v0.29.0

func (u *UI) Faint(s string) string

func (*UI) Hint added in v0.23.0

func (u *UI) Hint(str string, noPadding bool, label *string)

Hint handles the ui output for hint/onboarding messages, when enabled

func (*UI) Info added in v0.28.1

func (u *UI) Info(format string, args ...interface{})

Info handles outputting secondary information to the user such as messages about progress but are the actual result of an operation. For example, printing out that we're attempting to log a user in using the specific environment variables.

Only printed if stdout is attached to a terminal.

func (*UI) Line added in v0.23.0

func (u *UI) Line(format string, a ...interface{})

Line writes a formatted string followed by a newline to stdout. Output is word wrapped, and terminated by a newline.

func (*UI) LineIndent added in v0.23.0

func (u *UI) LineIndent(indent int, format string, a ...interface{})

LineIndent writes a formatted string followed by a newline to stdout. Output is word wrapped, and terminated by a newline. All lines after the first are indented by indent number of spaces (in addition to the indenting enforced by this UI instance.

func (*UI) Progress added in v0.23.0

func (u *UI) Progress(str string)

Progress handles the ui output for progress events, when enabled

func (*UI) Warn added in v0.28.1

func (u *UI) Warn(format string, args ...interface{})

Warn handles outputting warning information to the user such as messages about needing to be logged in.

The warning is printed out to stderr if stdout is not attached to a terminal.

func (*UI) Write added in v0.23.0

func (u *UI) Write(p []byte) (n int, err error)

Write implements the io.Writer interface The provided bytes are split on newlines, and written with the UI's configured indent.

type UIColor added in v0.29.0

type UIColor int
const (
	Default UIColor
	Black
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	Gray
	DarkGray
	BrightRed
	BrightGreen
	BrightYellow
	BrightBlue
	BrightMagenta
	BrightCyan
	White
)

Jump to

Keyboard shortcuts

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