Documentation
¶
Index ¶
- Constants
- Variables
- func Ask(qs []*Question) (map[string]string, error)
- func AskOne(p Prompt) (string, error)
- func AskOneValidate(p Prompt, v Validator) (string, error)
- func Required(str string) error
- func RunTemplate(tmpl string, data interface{}) (string, error)
- type Choice
- type Confirm
- type ConfirmTemplateData
- type Input
- type InputTemplateData
- type MultiChoice
- type MultiChoiceTemplateData
- type Password
- type Prompt
- type Question
- type SelectTemplateData
- type Validator
Constants ¶
const ( SelectQuestionTemplate = `` /* 175-byte string literal not displayed */ // the template used to show the list of Selects SelectChoicesTemplate = `` /* 191-byte string literal not displayed */ )
Variables ¶
var ConfirmQuestionTemplate = `` /* 268-byte string literal not displayed */
Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format
var DisableColor = false
var ErrorTemplate = `{{color "red"}}✘ Sorry, your reply was invalid: {{.Error}}{{color "reset"}}
`
var InputQuestionTemplate = `` /* 263-byte string literal not displayed */
Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format
var MultiChoiceOptionsTemplate = `` /* 271-byte string literal not displayed */
var MultiChoiceQuestionTemplate = `` /* 181-byte string literal not displayed */
var PasswordQuestionTemplate = `
{{- color "green+hb"}}? {{color "reset"}}
{{- color "default+hb"}}{{ .Message }} {{color "reset"}}`
Templates with Color formatting. See Documentation: https://github.com/mgutz/ansi#style-format
var TemplateFuncs = map[string]interface{}{ "color": func(color string) string { if DisableColor { return "" } return ansi.ColorCode(color) }, }
Functions ¶
func AskOneValidate ¶
AskOneValidate asks a single question and validates the answer with v.
func RunTemplate ¶
Types ¶
type Choice ¶
Choice is a prompt that presents a list of various options to the user for them to select using the arrow keys and enter.
type Confirm ¶
Confirm is a regular text input that accept yes/no answers.
type ConfirmTemplateData ¶
data available to the templates when processing
type Input ¶
Input is a regular text input that prints each character the user types on the screen and accepts the input with the enter key.
type InputTemplateData ¶
data available to the templates when processing
type MultiChoice ¶
type MultiChoice struct { Message string Options []string Defaults []string Answer *[]string // contains filtered or unexported fields }
MultiChoice is a prompt that presents a list of various options to the user for them to select using the arrow keys and enter.
func (*MultiChoice) Cleanup ¶
func (m *MultiChoice) Cleanup(rl *readline.Instance, val string) error
Cleanup removes the options section, and renders the ask like a normal question.
type MultiChoiceTemplateData ¶
type MultiChoiceTemplateData struct { MultiChoice Answer []string Checked map[int]bool SelectedIndex int }
data available to the templates when processing
type Password ¶
type Password struct {
Message string
}
Password is like a normal Input but the text shows up as *'s and there is no default.
type Prompt ¶
type Prompt interface { Prompt(*readline.Instance) (string, error) Cleanup(*readline.Instance, string) error }
Prompt is the primary interface for the objects that can take user input and return a string value.
type SelectTemplateData ¶
the data available to the templates when processing