package
0.8.0
Repository: https://github.com/adnsv/go-utils.git
Documentation: pkg.go.dev

# Functions

Ask is a show a generic prompt asking for user input, with validation.
AutoYN configures automatic YN answers for non-interactive runs.
Choose shows a prompt as: <prompt> 1: <choices[0]> 2: <choices[1]> ..
Enum shows a prompt as: <promptPrefix> [<choices[0]>/<choices[1]>/.../<choices[N-1]>]: _ Then it awaits user input as text value and returns the matching chose as a string.
Int shows a prompt and processes user input as a typed integer value, accepting values between min and max.
NoEmptyString can be used as validating callback for Text and TextTrimmed calls.
No description provided by the author
Text shows a prompt as: <prompt> _ Then it awaits user input as text, validates it with the provided validation callbacks and returns the typed value if validation was successful.
TextTrimmed works similarly to Text, but trims spaces from typed string before it is validated and returned some of the validators are defined below note that you can also use Validate* functions from filesystem.stats.
YN displays a [y/n] prompt, returning a boolean value after the user types a response - 'y'|'yes' -> returns true - 'n'|'no' -> returns false # Automatic answers are configured globally with AutoYN() and can be overriden with NoAuto policy Default answers (when user hits RETURN key without typing anything) can be configured with DefaultY or DefaultN policy.

# Constants

always prompt.
ignore prompt, automatically assume no.
ignore prompt, automatically assume yes.
assume 'n' when user provides empty input (hits RETURN key without typing anything).
assume 'y' when user provides empty input (hits RETURN key without typing anything).
ignore YNAuto, always show prompt.

# Variables

predefined validator errors.
No description provided by the author
No description provided by the author

# Type aliases

YNAuto allows to configure global automatic answers to YN, this may be useful for cli applications that expose '-y' or '-n' flags to bypass interactive Y/N choices (see AutoYN function).
YNPolicy provides tuning options for AskYN prompts.