Documentation
¶
Index ¶
- Variables
- func AdvisoryColor(message string) string
- func Colorize(message string, color *color.Color) string
- func ColorsEnabled() bool
- func CommandColor(message string) string
- func CrashedColor(message string) string
- func Decolorize(message string) string
- func EntityNameColor(message string) string
- func FailureColor(message string) string
- func HeaderColor(message string) string
- func InitColorSupport()
- func LogAppHeaderColor(message string) string
- func LogHealthHeaderColor(message string) string
- func LogStderrColor(message string) string
- func LogStdoutColor(message string) string
- func LogSysHeaderColor(message string) string
- func PromptColor(message string) string
- func StoppedColor(message string) string
- func SuccessColor(message string) string
- func TableContentHeaderColor(message string) string
- func WarningColor(message string) string
- type PrintableTable
- type Prompt
- type PromptOptions
- type Table
- type UI
- type ValidateFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Output = colorable.NewColorableStdout() ErrOutput = colorable.NewColorableStderr() TerminalSupportsColors = isTerminal() UserAskedForColors = "" )
View Source
var ( ErrInputEmpty = errors.New("input is empty") ErrInputNotNumber = errors.New("input is not a number") ErrInputNotFloatNumber = errors.New("input is not a floating point number") ErrInputNotBool = errors.New("input must be 'y', 'n', 'yes' or 'no'") ErrInputOutOfRange = errors.New("input is out of range") )
Functions ¶
func AdvisoryColor ¶
func ColorsEnabled ¶
func ColorsEnabled() bool
func CommandColor ¶
func CrashedColor ¶
func Decolorize ¶
func EntityNameColor ¶
func FailureColor ¶
func HeaderColor ¶
func InitColorSupport ¶
func InitColorSupport()
func LogAppHeaderColor ¶
func LogHealthHeaderColor ¶
func LogStderrColor ¶
func LogStdoutColor ¶
func LogSysHeaderColor ¶
func PromptColor ¶
func StoppedColor ¶
func SuccessColor ¶
func TableContentHeaderColor ¶
func WarningColor ¶
Types ¶
type PrintableTable ¶
type PrintableTable struct {
// contains filtered or unexported fields
}
func (*PrintableTable) Add ¶
func (t *PrintableTable) Add(row ...string)
func (*PrintableTable) Print ¶
func (t *PrintableTable) Print()
type Prompt ¶
Prompt represents a terminal prompt. Create Prompt with NewPrompt or NewChoicesPrompt
func NewChoicesPrompt ¶
func NewChoicesPrompt(message string, choices []string, options *PromptOptions) *Prompt
NewChoicesPrompt returns a choice prompt
func NewPrompt ¶
func NewPrompt(message string, options *PromptOptions) *Prompt
NewPrompt returns a single prompt
type PromptOptions ¶
type PromptOptions struct {
Required bool // If true, user input is required
HideInput bool // If true, user input is hide, typically when asking password. TODO: support mask later
HideDefault bool // If true, hide default value in the prompt message
NoLoop bool // if true, when input is invalid, return error instead of asking user for retry
ValidateFunc ValidateFunc // customized input validation function
}
type UI ¶
type UI interface {
// Deprecated: this method could be removed in the future,
// Use Info() if the message is printed to StdErr and it will be suppressed in quiet mode
// Or use Verbose() if the message is printed to StdOut and it will be suppressed in quiet mode
// Say prints the formated message to StdOut, the message will NOT be suppressed in quiet mode
Say(format string, args ...interface{})
// Verbose prints message to StdOut, the message will be suppressed in quiet mode
Verbose(format string, args ...interface{})
// Info prints message to StdErr, the message will be suppressed in quiet mode
Info(format string, args ...interface{})
// Warn prints the formated warning message to StdErr, the message will be suppressed in quiet mode
Warn(format string, args ...interface{})
// Failed prints the formated failure message to StdErr, word `FAILED` will be suppressed in quiet mode.
// But the message itself will NOT be suppressed.
Failed(format string, args ...interface{})
// Print will send the message to StdOut, the message will NOT be suppressed in quiet mode
Print(format string, args ...interface{})
// OK prints 'OK' to StdOut, the message will be suppressed in quiet mode
Ok()
// Prompt creates a single Prompt
Prompt(message string, options *PromptOptions) *Prompt
// ChoicePrompt creates a choice prompt
ChoicesPrompt(message string, choices []string, options *PromptOptions) *Prompt
// Ask asks for text answer
// Deprecated: use Prompt instead
Ask(format string, args ...interface{}) (answer string, err error)
// AskForPassword asks for password
// Deprecated: use Prompt instead
AskForPassword(format string, args ...interface{}) (answer string, err error)
// Confirm asks for user confirmation
// Deprecated: use Prompt instead
Confirm(format string, args ...interface{}) (bool, error)
// ConfirmWithDefault asks for user confirmation. If user skipped, return
// defaultBool Deprecated: use Prompt instead
ConfirmWithDefault(defaultBool bool, format string, args ...interface{}) (bool, error)
// SelectOne asks to select one from choices. It returns the selected index.
// Deprecated: use ChoicesPrompt instead
SelectOne(choices []string, format string, args ...interface{}) (int, error)
// Table creates a table with the given headers
Table(headers []string) Table
// Writer returns writer of the terminal UI
Writer() io.Writer
// Enable or disable quiet mode. Contents passed to Verbose(), Warn(), OK() will be ignored if under quiet mode.
SetQuiet(bool)
// Return whether quiet mode is enabled or not
Quiet() bool
}
UI provides utilities to handle input and output streams
type ValidateFunc ¶
Click to show internal directories.
Click to hide internal directories.