Documentation
¶
Overview ¶
Package promptui provides ui elements for the command line prompt.
Index ¶
Constants ¶
const ( FGBold attribute FGFaint FGItalic FGUnderline )
Forground weight/decoration attributes.
const ( FGBlack attribute = iota + 30 FGRed FGGreen FGYellow FGBlue FGMagenta FGCyan FGWhite )
Forground color attributes
const SelectedAdd = -1
SelectedAdd is returned from SelectWithAdd when add is selected.
Variables ¶
var ( IconInitial = Styler(FGBlue)("?") IconGood = Styler(FGGreen)("✔") IconWarn = Styler(FGYellow)("⚠") IconBad = Styler(FGRed)("✗") )
Icons used for displaying prompts or status
var ErrAbort = errors.New("")
ErrAbort is returned when confirm prompts are supplied "n"
var ErrEOF = errors.New("^D")
ErrEOF is returned from prompts when EOF is encountered.
var ErrInterrupt = errors.New("^C")
ErrInterrupt is returned from prompts when an interrupt (ctrl-c) is encountered.
var ResetCode = fmt.Sprintf("%s%dm", esc, reset)
ResetCode is the character code used to reset the terminal formatting
Functions ¶
func FailedValue ¶
FailedValue returns a value as if it were entered via prompt, invalid
func Styler ¶ added in v0.23.0
Styler returns a func that applies the attributes given in the Styler call to the provided string.
func SuccessfulValue ¶
SuccessfulValue returns a value as if it were entered via prompt, valid
Types ¶
type Prompt ¶
type Prompt struct {
Label string // Label is the value displayed on the command line prompt
Default string // Default is the initial value to populate in the prompt
// Validate is optional. If set, this function is used to validate the input
// after each character entry.
Validate ValidateFunc
// If mask is set, this value is displayed instead of the actual input
// characters.
Mask rune
IsConfirm bool
IsVimMode bool
Preamble *string
// Indent will be placed before the prompt's state symbol
Indent string
// contains filtered or unexported fields
}
Prompt represents a single line text field input.
type Select ¶
type Select struct {
Label string // Label is the value displayed on the command line prompt.
Items []string // Items are the items to use in the list.
IsVimMode bool // Whether readline is using Vim mode.
}
Select represents a list for selecting a single item
type SelectWithAdd ¶
type SelectWithAdd struct {
Label string // Label is the value displayed on the command line prompt.
Items []string // Items are the items to use in the list.
AddLabel string // The label used in the item list for creating a new item.
// Validate is optional. If set, this function is used to validate the input
// after each character entry.
Validate ValidateFunc
IsVimMode bool // Whether readline is using Vim mode.
}
SelectWithAdd represents a list for selecting a single item, or selecting a newly created item.
type ValidateFunc ¶
ValidateFunc validates the given input. It should return a ValidationError if the input is not valid.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is the class of errors resulting from invalid inputs, returned from a ValidateFunc.
func NewValidationError ¶
func NewValidationError(msg string) *ValidationError
NewValidationError creates a new validation error with the given message.
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string
Error implements the error interface for ValidationError.