5 个版本 (2 个稳定版)
1.1.0 | 2022年4月30日 |
---|---|
1.0.0 | 2022年1月18日 |
0.1.2 | 2020年11月25日 |
0.1.1 | 2020年11月25日 |
0.1.0 | 2020年11月24日 |
在 命令行界面 中排名 #560
12KB
211 行(不含注释)
确认
一个简单的脚本确认工具。确认成功时返回零,否则返回非零值。
$ confirm "Echo something?" -a 3 && echo something
Echo something? [y/n]:
Echo something? [y/n]:
Echo something? [y/n]: y
something
安装
目前,必须使用 cargo install confirm-rs
安装。平台支持由 getch
crate 决定。
您也可以下载代码并从源代码构建。
用户指南
最新的文档维护在工具的 --help
输出中,如下所示。
confirm --help
输出
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.
依赖关系
~3.5MB
~66K SLoC