kahkhang / Inquirer.sh

Modern terminal prompt inspired by inquirer.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Text Input: No blanks, validation fails, default not possible

Fmstrat opened this issue · comments

Perhaps this is user error with the new version, but there is no example that demonstrates how to use anything but the default when default is set.

For instance, from https://github.com/kahkhang/Inquirer.sh/blob/master/examples/text_input_example.sh, there is:

text_input "Gender" gender "Male"

However, if you use this, it doesn't show a default, instead it fails validation unless your answer is the default. So basically, you MUST type "Male" to get out of the prompt.

I also don't see any details on how to use the validation. I'd like to do something like this:

text_input "What IP range should the server use?" IP_RANGE "192.168.99.1/24" "Invalid IP range format." ???????

But even if this was working, I'm not sure what to include here. The name of a previously defined function?

Thanks!

As a note, I would expect to see something like this, where I could press enter to select the default:

printf "${green}?${normal} What IP range should the server use [${dim}192.168.99.1/24${normal}]?"