promptutil

package
v1.0.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PasswordReader = passwordReaderFunc

PasswordReader has passwordReaderFunc as the default but can be changed for testing purposes.

Functions

func DefaultAndValidatePrompt

func DefaultAndValidatePrompt(promptText, defaultValue string, validateFunc func(string) error) (string, error)

DefaultAndValidatePrompt prompts the user for any text and expects it to fulfill a validation function. If nothing is entered the default value is returned.

func DefaultPrompt

func DefaultPrompt(promptText, defaultValue string) (string, error)

DefaultPrompt prompts the user for any text and performs no validation. If nothing is entered it returns the default.

func InputPassword

func InputPassword(
	cliCtx *cli.Context,
	passwordFileFlag *cli.StringFlag,
	promptText, confirmText string,
	shouldConfirmPassword bool,
	passwordValidator func(input string) error,
) (string, error)

InputPassword with a custom validator along capabilities of confirming the password and reading it from disk if a specified flag is set.

func IsValidUnicode

func IsValidUnicode(input string) bool

IsValidUnicode checks if an input string is a valid unicode string comprised of only letters, numbers, punctuation, or symbols.

func NotEmpty

func NotEmpty(input string) error

NotEmpty is a validation function to make sure the input given isn't empty and is valid unicode.

func PasswordPrompt

func PasswordPrompt(promptText string, validateFunc func(string) error) (string, error)

PasswordPrompt prompts the user for a password, that repeatedly requests the password until it qualifies the passed in validation function.

func ValidateConfirmation

func ValidateConfirmation(input string) error

ValidateConfirmation makes sure the entered text is the user confirming.

func ValidateNumber

func ValidateNumber(input string) error

ValidateNumber makes sure the entered text is a valid number.

func ValidatePasswordInput

func ValidatePasswordInput(input string) error

ValidatePasswordInput validates a strong password input for new accounts, including a min length, at least 1 number and at least 1 special character.

func ValidatePhrase

func ValidatePhrase(input, wantedPhrase string) error

ValidatePhrase checks whether the user input is equal to the wanted phrase. The verification is case sensitive.

func ValidatePrompt

func ValidatePrompt(r io.Reader, promptText string, validateFunc func(string) error) (string, error)

ValidatePrompt requests the user for text and expects the user to fulfill the provided validation function.

func ValidateYesOrNo

func ValidateYesOrNo(input string) error

ValidateYesOrNo ensures the user input either Y, y or N, n.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL