8 个版本 (4 个重大更新)
0.6.1 | 2022年2月17日 |
---|---|
0.6.0 | 2022年2月13日 |
0.5.1 | 2021年10月9日 |
0.5.0 | 2020年10月18日 |
0.2.0 | 2020年1月17日 |
#1163 在 开发工具
每月94 次下载
在 gitmoji 中使用
21KB
302 行
enquirer
时尚交互式提示的命令行实用程序
(使用 dialoguer)
入门
使用 Enquirer 入门,这是最强大的命令行实用程序,用于创建交互式 CLI 提示。
安装
enquirer
可在 Linux、macOS 上使用
通过 Homebrew
$ brew install termapps/tap/enquirer
这是在 macOS 上更新到新版本后更新容易的推荐安装方式。
通过 cargo
$ cargo install enquirer
直接
预构建的二进制可执行文件可在 发布页面 获取,适用于 macOS (64位)、Linux (64位、32位)。
下载并解压缩二进制文件,然后将可执行文件放在 $PATH
中。
查看 路线图 了解其他方法
用法
命令行实用程序
我创建此工具的主要原因是为 bash 脚本使用它作为时尚的交互式且用户友好的提示。
#!/bin/bash
confirm=$(enquirer confirm -m "Do you want to continue?" -d)
if [ "$confirm" = "true" ]; then
echo "Continuing ..."
else
echo "Thanks for using this tool. Quitting ..."
exit
fi
有关子命令的更多信息,请参阅 提示。
enquirer 0.5.1
Command Line Utility for Stylish Interactive Prompts
USAGE:
enquirer [FLAGS] <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
--no-color Disable colors in the prompt
-V, --version Prints version information
SUBCOMMANDS:
confirm Prompt that returns `true` or `false` (as strings)
help Prints this message or the help of the given subcommand(s)
input Prompt that takes user input and returns a string
multi-select Prompt that allows the user to select multiple items from a list of options
secret Prompt that takes user input, hides it from the terminal, and returns a string
select Prompt that allows the user to select from a list of options
sort Prompt that allows the user to sort items in a list
提示
确认提示
返回 true
或 false
(作为字符串)的提示
用法
enquirer-confirm 0.5.1
Prompt that returns `true` or `false` (as strings)
USAGE:
enquirer confirm [FLAGS] --message <message>
FLAGS:
-c, --cancel Makes the prompt cancellable with 'Esc' or 'q'
-d, --default Sets the default value for the prompt as `true`
-h, --help Prints help information
OPTIONS:
-m, --message <message> Message for the prompt
输入提示
获取用户输入并返回字符串的提示
用法
enquirer-input 0.5.1
Prompt that takes user input and returns a string
USAGE:
enquirer input [FLAGS] [OPTIONS] --message <message>
FLAGS:
-a, --allow-empty Allow empty input. Conflicts with `default`
-h, --help Prints help information
OPTIONS:
-d, --default <default> Default value for the prompt
-m, --message <message> Message for the prompt
秘密提示
获取用户输入,将其隐藏在终端中,并返回字符串的提示
用法
enquirer-secret 0.5.1
Prompt that takes user input, hides it from the terminal, and returns a string
USAGE:
enquirer secret [FLAGS] [OPTIONS] --message <message>
FLAGS:
-a, --allow-empty Allow empty secret
-h, --help Prints help information
OPTIONS:
-c, --confirm <confirm> Enable confirmation prompt with this message
-e, --error <error> Error message when secrets doesn't match during confirmation
-m, --message <message> Message for the prompt
选择提示
允许用户从选项列表中选择提示
用法
enquirer-select 0.5.1
Prompt that allows the user to select from a list of options
USAGE:
enquirer select [FLAGS] [OPTIONS] --message <message> [items]...
FLAGS:
-c, --cancel Makes the prompt cancellable with 'Esc' or 'q'
-h, --help Prints help information
-i, --index Returns index of the selected item instead of item itself
OPTIONS:
-m, --message <message> Message for the prompt
-s, --selected <selected> Specify number of the item that will be selected by default
ARGS:
<items>... Items that can be selected
多选提示
允许用户从选项列表中选择多个项目的提示
用法
enquirer-multi-select 0.5.1
Prompt that allows the user to select multiple items from a list of options
USAGE:
enquirer multi-select [FLAGS] [OPTIONS] --message <message> [--] [items]...
FLAGS:
-c, --cancel Makes the prompt cancellable with 'Esc' or 'q'
-h, --help Prints help information
-i, --index Returns index of the selected items instead of items itself
--no-inline Do not print the selected items on the prompt line
-d, --default Makes the prompt return default values as given if --cancel option is present
OPTIONS:
-m, --message <message> Message for the prompt
-s, --selected <selected>... Specify numbers of items that will be selected by default
ARGS:
<items>... Items that can be selected
排序提示
允许用户对列表中的项目进行排序的提示
用法
enquirer-sort 0.5.1
Prompt that allows the user to sort items in a list
USAGE:
enquirer sort [FLAGS] --message <message> [items]...
FLAGS:
-c, --cancel Makes the prompt cancellable with 'Esc' or 'q'
-h, --help Prints help information
-i, --index Returns index of the sorted items instead of items itself
--no-inline Do not print the sorted items on the prompt line
-d, --default Makes the prompt return default order as given if --cancel option is present
OPTIONS:
-m, --message <message> Message for the prompt
ARGS:
<items>... Items that can be sorted
关于
路线图
- 生成手册页
- 其他操作系统的打包
- 自动完成提示(类似于 fzf)
- 代码片段提示
- 为 Clap 提供导出钩子
Dialoguer 的问题
- 在等待用户时,选择和多选提示的游标位于项目列表之后。可能需要将它们移动到提示行。
变更日志
请参阅 CHANGELOG.md。
许可证
MIT/X11
错误报告
在此处报告。
创建者
Pavan Kumar Sunkara ([email protected])
依赖项
~3–11MB
~110K SLoC