terminal

package
v0.0.0-...-84e757a Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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 AdvisoryColor(message string) string

func Colorize

func Colorize(message string, color Color) string

func ColorizeBold

func ColorizeBold(message string, color Color) string

func ColorsEnabled

func ColorsEnabled() bool

func CommandColor

func CommandColor(message string) string

func CrashedColor

func CrashedColor(message string) string

func Decolorize

func Decolorize(message string) string

func EntityNameColor

func EntityNameColor(message string) string

func FailureColor

func FailureColor(message string) string

func HeaderColor

func HeaderColor(message string) string

func InitColorSupport

func InitColorSupport()

func LogAppHeaderColor

func LogAppHeaderColor(message string) string

func LogHealthHeaderColor

func LogHealthHeaderColor(message string) string

func LogStderrColor

func LogStderrColor(message string) string

func LogStdoutColor

func LogStdoutColor(message string) string

func LogSysHeaderColor

func LogSysHeaderColor(message string) string

func PromptColor

func PromptColor(message string) string

func StoppedColor

func StoppedColor(message string) string

func SuccessColor

func SuccessColor(message string) string

func TableContentHeaderColor

func TableContentHeaderColor(message string) string

func WarningColor

func WarningColor(message string) string

Types

type Color

type Color uint

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

type Prompt struct {
	Reader io.Reader
	Writer io.Writer
	// contains filtered or unexported fields
}

Create Prompt with NewPrompt or NewChoicesPrompt

func NewChoicesPrompt

func NewChoicesPrompt(message string, choices []string, options *PromptOptions) *Prompt

func NewPrompt

func NewPrompt(message string, options *PromptOptions) *Prompt

func (*Prompt) Resolve

func (p *Prompt) Resolve(dest interface{}) error

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 Table

type Table interface {
	Add(row ...string)
	Print()
}

func NewTable

func NewTable(w io.Writer, headers []string) Table

type UI

type UI interface {
	Say(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Failed(format string, args ...interface{})
	Ok()

	Prompt(message string, options *PromptOptions) *Prompt
	ChoicesPrompt(message string, choices []string, options *PromptOptions) *Prompt

	// Deprecated: use Prompt() instead
	Ask(format string, args ...interface{}) (answer string)
	// Deprecated: use Prompt() instead
	AskForPassword(format string, args ...interface{}) (answer string)
	// Deprecated: use Prompt() instead
	Confirm(format string, args ...interface{}) bool
	// Deprecated: use Prompt() instead
	ConfirmWithDefault(defaultBool bool, format string, args ...interface{}) bool
	// Deprecated: use ChoicesPrompt() instead
	SelectOne(choices []string, format string, args ...interface{}) int

	Table(headers []string) Table
	Writer() io.Writer
}

func NewStdUI

func NewStdUI() UI

func NewUI

func NewUI(in io.Reader, out io.Writer) UI

type ValidateFunc

type ValidateFunc func(string) error

Jump to

Keyboard shortcuts

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