kahkhang / inquirer.sh Goto Github PK
View Code? Open in Web Editor NEWModern terminal prompt inspired by inquirer.js
License: MIT License
Modern terminal prompt inspired by inquirer.js
License: MIT License
OPTIONS=()
OPTIONS+=( "One" )
list_input "Which one?" OPTIONS CHOICE
When you use the above code, pressing up or down causes "One" to repeat on every line, vs forcing you to stay in place.
Unable to enter any of the following characters in text_input prompt. ` \ ; ' ~ # % & ( ) | : " < >
If we press ctrl-c during execution the final position of the cursor can be improved. Ideally preserve the screen and place the cursor at the end of screen.
Steps to recreate:
source checkbox_input.sh
hawker_centres=( 'Old Airport Road Hawker Centre' 'Golden Mile Food Complex' 'Maxwell Food Centre' 'Newton Food Centre' )
checkbox_input selected_hawkers "Which hawker centres do you prefer?" hawker_centres
echo "Selected indices $(join "${selected_hawkers[@]}")"
echo "Selected Hawker Centers:"
for i in $(seq 1 ${#selected_hawkers[@]}); do
echo "${hawker_centres[${selected_hawkers[$i]}]}"
done
Somehow there's this lex
behind the Selected Hawker Centers:
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!
Any luck with zsh & bash support?
That's a nice a project.
Just wanted to let you know that I wrote a list selection script in pure bash/zsh.
Take a look (redundant link in case project rename):
If you source dist/Inquirer.sh
after running text_input
, list_input
, or checkbox_input
, the shell stays in stty -echo
mode.
It also uses the “exit on error” option (set -e) that will force the shell to exit on any command with a non-zero exit status, which in turn may break scripts that source the inquirer scripts.
I suggest optionally enabling the set -e
option is the script is not sourced, or better yet, unset the e
flag if it was not set prior to the inquirer scripts:
#!/usr/bin/env bash <- I also recommend this instead of #!/bin/bash
# save the set options
OLD_SET=$-
...
# in cleanup part
if [[ $OLD_SET =~ e ]]
then set -e
else set +e
fi
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.