Crates.io | confirm-rs |
lib.rs | confirm-rs |
version | 1.1.0 |
source | src |
created_at | 2020-11-24 23:21:04.361523 |
updated_at | 2022-04-30 06:15:25.317208 |
description | A simple tool to obtain interactive confirmation in scripts. |
homepage | https://github.com/scruffystuffs/confirm |
repository | https://github.com/scruffystuffs/confirm |
max_upload_size | |
id | 316104 |
size | 19,774 |
A simple tool for scripted confirmation. Returns zero if confirmed, non-zero otherwise.
$ confirm "Echo something?" -a 3 && echo something
Echo something? [y/n]:
Echo something? [y/n]:
Echo something? [y/n]: y
something
Currently, must be installed using cargo install confirm-rs
. Platform support is determined by the getch
crate.
You can also download the code and build from source.
The up-to-date docs are maintained in the --help
output of the tool, copied below.
confirm --help
output:
confirm-rs 1.1.0
A simple tool to obtain interactive confirmation in scripts.
USAGE:
confirm [OPTIONS] [PROMPT]
ARGS:
<PROMPT>
The prompt to display
Prompt of "Continue?" will become "Continue? [y/n]: ". Options are added and
highlighted based on given settings. Original message will NEVER be modified.
[default: Continue?]
OPTIONS:
-a, --ask-count <ASK_COUNT>
Number of times to ask
Number of total times a question should be asked. Use 0 for infinite retries.
[default: 3]
-d, --default <DEFAULT>
Choose a default answer
If no default is chosen, and the user supplies an empty answer, then a retry is
triggered. Otherwise, the default is used on an empty answer. If the retry count has
been hit, then the process assumes a negative response and exits 1. Using the keyword
"retry" is identical to omitting the option.
[default: retry]
-f, --full-words
Require explicit "yes" or "no", not single letters.
Cannot be used with --no-enter.
-h, --help
Print help information
--no
Don't ask any question, fail immediately.
Turns the tool into no-op failure. Useful when testing shell scripts built around this
tool.
--no-enter
Don't require newlines
Read the character on the terminal as it's typed, without waiting for the user to hit
enter/return.
-V, --version
Print version information
--yes
Don't ask any question, return successfully.
Turns the entire tool into a no-op, useful when building shell scripts around the tool.