Ask -> Request, while Seek makes the answer optional

This commit is contained in:
Manuele Sarfatti 2025-05-20 17:33:11 +02:00
parent 5ff6a50d32
commit ce6bfcd04c
6 changed files with 93 additions and 33 deletions

View file

@ -78,10 +78,15 @@ pen "This is $(pen yellow "yellow"), and this is $(pen bold "bold")"
### Interactive Functions
```bash
# Ask for input
ask name "What's your name?"
# Kindly ask for input (empty answer is accepted)
seek name "What's your name?"
pen "Hello, $name!"
# Firmly ask for input (empty answer NOT accepted)
request name "No really, what's your name?"
pen "There you go, $name!"
# Yes/no confirmation (defaults to "yes")
if confirm "Continue?"; then
pen green "Continuing..."
@ -131,7 +136,8 @@ check "Task completed!" # We can directly `check`, `warn`, or `throw` after a `s
### User Interaction
- `ask [retval] PROMPT` - Get text input from user, saves the answer in `$retval`
- `seek [retval] PROMPT` - Get (optional) text input from user, saves the answer in `$retval`
- `request [retval] PROMPT` - Like above, but doesn't accept an empty response, saves the answer in `$retval`
- `confirm [OPTIONS] PROMPT` - Get yes/no input
- `--default-yes` - Set default answer to "yes" (default behavior)
- `--default-no` - Set default answer to "no"