Documentation ¶
Index ¶
- Variables
- func Address() promptui.ValidateFunc
- func DNS() promptui.ValidateFunc
- func IPAddress() promptui.ValidateFunc
- func NamedSelectTemplates(name string) *promptui.SelectTemplates
- func NotEmpty() promptui.ValidateFunc
- func Print(args ...interface{}) error
- func PrintSelected(name, value string, opts ...Option) error
- func PrintSelectedTemplate() string
- func Printf(format string, args ...interface{}) error
- func Println(args ...interface{}) error
- func Prompt(label string, opts ...Option) (string, error)
- func PromptPassword(label string, opts ...Option) ([]byte, error)
- func PromptPasswordGenerate(label string, opts ...Option) ([]byte, error)
- func PromptTemplates() *promptui.PromptTemplates
- func PromptYesNo(label string, opts ...Option) (bool, error)
- func Select(label string, items interface{}, opts ...Option) (int, string, error)
- func SelectTemplates(name string) *promptui.SelectTemplates
- func SimplePromptTemplates() *promptui.PromptTemplates
- func YesNo() promptui.ValidateFunc
- type Option
- func WithAllowEdit(b bool) Option
- func WithDefaultValue(s string) Option
- func WithMask(r rune) Option
- func WithPrintTemplate(template string) Option
- func WithPromptTemplates(t *promptui.PromptTemplates) Option
- func WithRichPrompt() Option
- func WithSelectTemplates(t *promptui.SelectTemplates) Option
- func WithSimplePrompt() Option
- func WithValidateFunc(fn func(string) error) Option
- func WithValidateNotEmpty() Option
- func WithValidateRegexp(re string) Option
- func WithValidateYesNo() Option
- func WithValue(value string) Option
Constants ¶
This section is empty.
Variables ¶
var ( // IconInitial is the icon used when starting in prompt mode and the icon next to the label when // starting in select mode. IconInitial = promptui.Styler(promptui.FGBlue)("?") // IconGood is the icon used when a good answer is entered in prompt mode. IconGood = promptui.Styler(promptui.FGGreen)("✔") // IconWarn is the icon used when a good, but potentially invalid answer is entered in prompt mode. IconWarn = promptui.Styler(promptui.FGYellow)("⚠") // IconBad is the icon used when a bad answer is entered in prompt mode. IconBad = promptui.Styler(promptui.FGRed)("✗") // IconSelect is the icon used to identify the currently selected item in select mode. IconSelect = promptui.Styler(promptui.FGBold)("▸") )
Functions ¶
func Address ¶
func Address() promptui.ValidateFunc
Address is a validation function that checks that the prompted string is a valid TCP address.
func DNS ¶
func DNS() promptui.ValidateFunc
DNS is a validation function that changes that the prompted string is a valid DNS name.
func IPAddress ¶
func IPAddress() promptui.ValidateFunc
IPAddress is validation function that checks that the prompted string is a valid IP address.
func NamedSelectTemplates ¶
func NamedSelectTemplates(name string) *promptui.SelectTemplates
NamedSelectTemplates returns the default promptui.SelectTemplate for struct slices with a name property. The given name is the prompt of the selected option.
func NotEmpty ¶
func NotEmpty() promptui.ValidateFunc
NotEmpty is a validation function that checks that the prompted string is not empty.
func Print ¶ added in v0.15.14
func Print(args ...interface{}) error
Print uses templates to print the arguments formated to os.Stderr.
func PrintSelected ¶
PrintSelected prints the given name and value as if they were selected from a promptui.Select.
func PrintSelectedTemplate ¶
func PrintSelectedTemplate() string
PrintSelectedTemplate returns the default template used in PrintSelected.
func Println ¶
func Println(args ...interface{}) error
Println uses templates to print the given arguments to os.Stderr
func PromptPassword ¶
PromptPassword creates and runs a promptui.Prompt with the given label. This prompt will mask the key entries with \r.
func PromptPasswordGenerate ¶
PromptPasswordGenerate creates and runs a promptui.Prompt with the given label. This prompt will mask the key entries with \r. If the result password length is 0, it will generate a new prompt with a generated password that can be edited.
func PromptTemplates ¶
func PromptTemplates() *promptui.PromptTemplates
PromptTemplates is the default style for a prompt.
func PromptYesNo ¶ added in v0.15.5
PromptYesNo creates and runs a promptui.Prompt with the given label, and returns true if the answer is y/yes and false if the answer is n/no.
func SelectTemplates ¶
func SelectTemplates(name string) *promptui.SelectTemplates
SelectTemplates returns the default promptui.SelectTemplate for string slices. The given name is the prompt of the selected option.
func SimplePromptTemplates ¶
func SimplePromptTemplates() *promptui.PromptTemplates
SimplePromptTemplates is a prompt with a simple style, used by default on password prompts.
func YesNo ¶
func YesNo() promptui.ValidateFunc
YesNo is a validation function that checks for a Yes/No answer.
Types ¶
type Option ¶
type Option func(*options)
Option is the type of the functions that modify the prompt options.
func WithAllowEdit ¶
WithAllowEdit if true, let's the user edit the default value set.
func WithDefaultValue ¶
WithDefaultValue adds a custom string as the default value.
func WithPrintTemplate ¶
WithPrintTemplate sets the template to use on the print methods.
func WithPromptTemplates ¶
func WithPromptTemplates(t *promptui.PromptTemplates) Option
WithPromptTemplates adds a custom template to a prompt.
func WithRichPrompt ¶
func WithRichPrompt() Option
WithRichPrompt add the template option with rich templates.
func WithSelectTemplates ¶
func WithSelectTemplates(t *promptui.SelectTemplates) Option
WithSelectTemplates adds a custom template to a select.
func WithSimplePrompt ¶
func WithSimplePrompt() Option
WithSimplePrompt add the template option with simple templates.
func WithValidateFunc ¶
WithValidateFunc adds a custom validation function to a prompt.
func WithValidateNotEmpty ¶
func WithValidateNotEmpty() Option
WithValidateNotEmpty adds a custom validation function to a prompt that checks that the propted string is not empty.
func WithValidateRegexp ¶ added in v0.15.5
WithValidateRegexp checks a prompt answer with a regular expression. If the regular expression is not a valid one, the option will panic.
func WithValidateYesNo ¶
func WithValidateYesNo() Option
WithValidateYesNo adds a custom validation function to a prompt for a Yes/No prompt.