ui

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attached added in v0.30.0

func Attached() bool

Attached return a boolean representing whether or not the current session is attached to a terminal or not.

func BoldColorString added in v0.30.0

func BoldColorString(c Color, s string) string

BoldColorString returns a bolded, colored copy of the string (ANSI escape sequenced)

func BoldString added in v0.30.0

func BoldString(s string) string

BoldString returns a bolded copy of the string (ANSI escape sequenced)

func ColorString added in v0.30.0

func ColorString(c Color, s string) string

ColorString returns the original string, converted to the provided ANSI color

func Error added in v0.28.1

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

Error calls Error on the default UI

func FaintString added in v0.30.0

func FaintString(s string) string

FaintString returns a faint (ANSI DarkGray) copy of the string (ANSI escape sequenced)

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 Warn added in v0.28.1

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

Warn calls Warn on the default UI

Types

type Color added in v0.29.0

type Color int

Color represents 1 of 16 ANSI color sequences

const (

	// Default sets the temrinal text to its default color
	Default Color
	// Black text
	Black
	// Red text
	Red
	//Green text
	Green
	// Yellow text
	Yellow
	// Blue text
	Blue
	// Magenta text
	Magenta
	// Cyan text
	Cyan
	// Gray text
	Gray
	// DarkGray text
	DarkGray
	// BrightRed text
	BrightRed
	// BrightGreen text
	BrightGreen
	// BrightYellow text
	BrightYellow
	// BrightBlue text
	BrightBlue
	// BrightMagenta text
	BrightMagenta
	// BrightCyan text
	BrightCyan
	// White text
	White
)

type Spinner added in v0.30.0

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner struct contains the spinner struct and display text

func NewSpinner added in v0.30.0

func NewSpinner(text string) *Spinner

NewSpinner calls NewSpinner on the default UI

func (*Spinner) Start added in v0.30.0

func (s *Spinner) Start()

Start displays the Spinner and starts movement

func (*Spinner) Stop added in v0.30.0

func (s *Spinner) Stop()

Stop halts the spiner movement and removes it from display

func (*Spinner) Update added in v0.30.0

func (s *Spinner) Update(text string)

Update changes the Spinner's suffix to 'text'

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) BoldColorString added in v0.30.0

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

BoldColorString checks the EnableColors pref and returns a bolded, colored copy of the string (ANSI escape sequenced)

func (*UI) BoldString added in v0.30.0

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

BoldString checks the EnableColors pref and returns a bolded copy of the string (ANSI escape sequenced)

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) ColorString added in v0.30.0

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

ColorString checks the EnableColors pref and returns a colored copy of the string (ANSI escape sequenced)

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) FaintString added in v0.30.0

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

FaintString checks the EnableColors pref and returns a faint (ANSI DarkGrey) copy of the string (ANSI escape sequenced)

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) NewSpinner added in v0.30.0

func (u *UI) NewSpinner(text string) *Spinner

NewSpinner creates a new ui.Spinner struct (spinner.go)

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.

Jump to

Keyboard shortcuts

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