Documentation
¶
Index ¶
Constants ¶
const ( LogStepSuccess = "Success" LogStepWarning = "Warning" LogStepError = "Error" )
const ( HeaderStyle = "header" ErrorStyle = "error" ErrorBoldStyle = "error-bold" WarningStyle = "warning" LogStyle = "log" WarningBoldStyle = "warning-bold" SuccessStyle = "success" SuccessBoldStyle = "success-bold" ErrorIndentChar = "✕" WarningIndentChar = "!" SuccessIndentChar = "✓" HeaderIndentChar = "»" LogIndentChar = "|" RecommendedWordWrapLimit = 80 )
Variables ¶
This section is empty.
Functions ¶
func FakeUIAndLog ¶
FakeUIAndLog returns a fake UI implementation and a log to help tracking of UI ops in tests.
Types ¶
type NamedValue ¶
type NamedValue struct {
Name string
Value interface{}
}
NamedValue outputs content in the format: key: value
type Option ¶
type Option func(*config)
Option controls output styling.
func WithErrorBoldStyle ¶
func WithErrorBoldStyle() Option
WithErrorBoldStyle configures output using the ErrorBoldStyle
func WithErrorStyle ¶
func WithErrorStyle() Option
WithErrorStyle configures output using the ErrorStyle
func WithIndentChar ¶
WithIndentChar configures output with an indent character
func WithWriter ¶
WithWriter specifies the writer for the output.
type Step ¶
type Step interface {
// Success completes a step marking it as successful, and starts the next step if there are any more steps.
Success(a ...interface{})
// Warning completes a step marking it as a warning, and starts the next step if there are any more steps.
Warning(a ...interface{})
// Error completes a step marking it as an error, stops execution of an next steps.
Error(a ...interface{})
}
type UI ¶
type UI interface {
// Output outputs a message directly to the terminal. The remaining
// arguments should be interpolations for the format string. After the
// interpolations you may add Options.
Output(msg string, opts ...Option)
// OutputWriters returns stdout and stderr writers. These are usually
// but not always TTYs. This is useful for subprocesses, network requests,
// etc. Note that writing to these is not thread-safe by default so
// you must take care that there is only ever one writer.
OutputWriters() (stdout, stderr io.Writer, err error)
// Header outputs a header style value to the screen
Header(msg string, opts ...Option)
NamedValues(rows []NamedValue, opts ...Option)
// StepGroup returns a value that can be used to output individual steps
// that have their own message, status indicator, spinner, and
// body. No other output mechanism (Output, Input, Status, etc.) may be
// called until the StepGroup is complete.
StepGroup() StepGroup
}
UI is the primary interface for interacting with a user via the CLI.
Some of the methods on this interface return values that have a lifetime such as StepGroup. While these are still active (haven't called the Done or equivalent method on these values), no other method on the UI should be called.
