| Crates.io | ask-yn |
| lib.rs | ask-yn |
| version | 0.3.0 |
| created_at | 2025-10-31 16:54:29.236178+00 |
| updated_at | 2025-12-20 15:13:25.014793+00 |
| description | Terminal utility program to prompt the user to answer yes or no. |
| homepage | https://github.com/zfzackfrost/ask-yn |
| repository | https://github.com/zfzackfrost/ask-yn |
| max_upload_size | |
| id | 1910329 |
| size | 13,131 |
Terminal utility program to prompt the user to answer yes or no.
Without a default argument, the program with ask the user again if no input is given.
if ask-yn "Do a task?"; then
echo "Doing a task"
else
echo "Task canceled"
fi
The output in this case should look something like the following. Program output is in bold, user input is in italic:
Do a task? [y/n] maybe
Unrecognized response! Do a task? [y/n]
Unrecognized response! Do a task? [y/n] yes
Doing a task
With a default argument, the program will use it when no input is provided.
if ask-yn "Do a task?" -d n; then
echo "Doing a task"
else
echo "Task canceled"
fi
The output in this case should look something like the following. Program output is in bold, user input is in italic:
Do a task? [y/N] maybe
Unrecognized response! Do a task? [y/N]
Task canceled
The -i/--invert flag in this program inverts the return code. With this
flag, the program will return a 1 when given a yes answer and a 0
otherwise.
if ask-yn "Don't do a task?" -i; then
echo "Task canceled"
else
echo "Doing a task"
fi