Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Red can be used as Sprintf, where the output it wrapped in escape characters which will render the text red in terminals. Red = color.New(color.Bold, color.FgRed).SprintfFunc() // Green can be used as Sprintf, where the output it wrapped in escape characters which will render the text green in terminals. Green = color.New(color.Bold, color.FgGreen).SprintfFunc() // Yellow can be used as Sprintf, where the output it wrapped in escape characters which will render the text yellow in terminals. Yellow = color.New(color.Bold, color.FgYellow).SprintfFunc() )
Functions ¶
func IntToCheckmark ¶
IntToCheckmark returns a string with ansi color instruction characters: a red ✘ if the argument is zero, a green ✔ otherwise.
func StringToCheckmark ¶
StringToCheckmark returns a string with ansi color instruction characters: a red ✘ if the argument is "0", a yellow ? if the argument is "", a green ✔ otherwise.
Types ¶
type Checkmark ¶
type Checkmark string
Checkmark type is a string with some functions attached.
func Btoc ¶ added in v1.4.6
Btoc returns a Checkmark from a boolean, red ✘ if the argument is false, a green ✔ otherwise.
type Converter ¶ added in v1.4.13
type Converter interface {
// Convert performs the conversion.
Convert(s string) (interface{}, error)
}
Converter converts strings to any type.
type Question ¶ added in v1.4.13
type Question struct {
Key string // Key identifies the target field name.
Text string // Text is presented to the user.
Converter Converter // Converter should map text input to a target type.
CustomSource func() (string, error) // CustomSource may replace the custom input source.
Defaulter func() interface{} // Defaulter may supply a fallback value when an empty input is supplied.
}
Question is a container for confronting the user to decide on an answer. codebeat:disable[TOO_MANY_IVARS]
func ForPassword ¶ added in v1.4.13
ForPassword creates a Question with a sting as target value. The input from the terminal will not be echoed.
type Survey ¶ added in v1.4.13
type Survey struct {
In io.Reader // In is the input source, e.g. os.Stdin.
Out io.Writer // Out is the output sink, e.g. os.Stdout.
}
Survey contains the configuration on how to present/obtain questions/answers to/from the user.
type Table ¶ added in v1.4.13
type Table struct {
// contains filtered or unexported fields
}
Table contains the data to draw a table.