Documentation ¶
Overview ¶
Package prompt provides a set of functions to prompt the user to enter a value.
Index ¶
- Constants
- Variables
- func Bool(label string) (bool, error)
- func Duration(label string, timeUnit timeUnit, maxAttempts int, ...) (time.Duration, error)
- func Number(label string, maxAttempts int, promptAgainCallback AgainCallback, ...) (int, error)
- func Password(label string, confirmLabel string, maxAttempts int, ...) (string, error)
- func Select(label string, items []string) (string, error)
- func Text(label string, isConfirm bool) (string, error)
- func Time(label string, layout string, maxAttempts int, ...) (time.Time, error)
- type AgainCallback
Constants ¶
View Source
const ( // Nanosecond timeUnit = "ns" Nanosecond timeUnit = "ns" // Microsecond timeUnit = "us" Microsecond timeUnit = "us" // Millisecond timeUnit = "ms" Millisecond timeUnit = "ms" // Second timeUnit = "s" Second timeUnit = "s" // Minute timeUnit = "m" Minute timeUnit = "m" // Hour timeUnit = "h" Hour timeUnit = "h" // Day timeUnit = "d" Day timeUnit = "d" // Week timeUnit = "w" Week timeUnit = "w" // Month timeUnit = "M" Month timeUnit = "M" // Year timeUnit = "y" Year timeUnit = "y" )
Variables ¶
View Source
var ( // ErrorMaxAttemptExceeded is returned when the maximum number of attempts is exceeded. ErrorMaxAttemptExceeded = fmt.Errorf("max attempts exceeded") // ErrorPasswordMismatch is returned when the password and the confirmation password do not match. ErrorPasswordMismatch = fmt.Errorf("password mismatch") // ErrorTimeDurationFormat is returned when the time duration format is invalid. ErrorTimeDurationFormat = fmt.Errorf("invalid time duration format") // ErrorTimeFormat is returned when the time format is invalid. ErrorTimeFormat = fmt.Errorf("invalid time format") // ErrorNumberFormat is returned when the number format is invalid. ErrorNumberFormat = fmt.Errorf("invalid number format") )
Functions ¶
func Duration ¶
func Duration( label string, timeUnit timeUnit, maxAttempts int, promptAgainCallback AgainCallback, isConfirm bool, ) (time.Duration, error)
Duration prompts the user to enter a duration.
func Number ¶
func Number( label string, maxAttempts int, promptAgainCallback AgainCallback, isConfirm bool, ) (int, error)
Number prompts the user to enter a number.
func Password ¶
func Password( label string, confirmLabel string, maxAttempts int, promptAgainCallback AgainCallback, isConfirm bool, ) (string, error)
Password prompts the user to enter a password.
Types ¶
type AgainCallback ¶
AgainCallback is a callback function that is called when the user needs to be prompted again.
Click to show internal directories.
Click to hide internal directories.