Ⅰ. 插件描述
Interactive prompt reader for fish-shellⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'fisherman/get'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'fisherman/get'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'fisherman/get'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/fisherman/get
Ⅳ. 文档说明
Get
Get is an interactive prompt reader for [fish]. Use with [read(1)] to validate and store user input such as passwords and other data into variables.
Install
With [fisherman]:
fisher getOptions
- -p, --prompt=msg: Set the prompt message.
- -r, --rule=regex: Use the Regular Expression regex to validate the input. This creates an infinite read loop until the input matches regex.
- -e, --error=msg: Set the error message. msg is a [printf(1)] format string. Use the first positional %s to display the read input.
- -s, --silent[=number]: Hide the user input as it is being typed. Use this option to handle passwords or other sensitive data. Optionally, indicate a number to read up to a certain number of characters instead of a new line by default.
- -d, --default=str: Use default value if none selected.
- -q, --quiet: Suppress standard output.
- --no-case: Ignore case during validation.
- --no-cursor: Hide cursor.
- -h, --help: Show usage help.
Usage
Get prints the user input to standard output by default.
get
Use --prompt=msg to display a prompt.
get --prompt "What's your name?\n-> "
Use --rule=regex to validate the user input.
get --prompt="Enter a number:" --rule="[0-9]"
Use --error=msg to display an error message when --rule=regex fails. The error message can be [printf(1)] format string and the user input can be displayed using %s.
get --prompt="Enter a number:" --rule="[0-9]" --error="'%s' is not a valid number."
Use --silent to hide the user input and read a password into a variable.
get --prompt="Enter your password:" --silent
Using --silent in combination with --rule and --error will hide the input from the error message using a star character *.
get --prompt="Enter your password:" --rule="[0-9]" --error="Invalid password '%s'" --silent
Use --no-cursor to hide the cursor and --silent=number to read up to number of characters too.
Use --quiet to suppress writing the read input to standard output.
get --prompt="Press any key to continue..." --no-cursor --silent=1