From 482fba234bd14ae8d042ce96f1f030d5bccdf6d5 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Wed, 26 Jan 2022 16:21:18 +0800 Subject: [PATCH] :memo: add nb-cli doc --- README.md | 14 ++++--- website/docs/start/nb-cli.md | 73 +++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 83fb2806..1af8e081 100644 --- a/README.md +++ b/README.md @@ -156,12 +156,14 @@ NoneBot2 不是 NoneBot1 的替代品。事实上,它们都在被积极的维 `NoneBot` 采用 `MIT` 许可证进行开源 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +```text +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` ## 贡献 diff --git a/website/docs/start/nb-cli.md b/website/docs/start/nb-cli.md index 6472d4e7..e80b0938 100644 --- a/website/docs/start/nb-cli.md +++ b/website/docs/start/nb-cli.md @@ -10,4 +10,75 @@ options: # 使用脚手架 - +## 安装 + +```bash +pip install nb-cli +``` + +## 初次使用 + +在安装完成之后,即可在命令行使用 `nb-cli` 的命令 `nb` 进行开发: + +```bash +# 直接使用 nb 命令 +nb +# 或使用 python 执行 module +python -m nb_cli +``` + +:::warning 注意 +通常情况下,你可以直接在命令行使用 `nb` 命令,但如果命令行出现 `Command not found` 错误,这是由于环境变量 `PATH` 没有正确配置或未配置导致的,可以使用第二种方式代替。 +::: + +## 使用方式 + +`nb-cli` 具有两种使用方式: + +1. 命令行指令 + + 查看帮助信息: + + ```bash + $ nb --help + Usage: nb [OPTIONS] COMMAND [ARGS]... + + Options: + -V, --version Show the version and exit. + --help Show this message and exit. + + ... + ``` + + 查看子命令帮助: + + ```bash + $ nb plugin --help + Usage: nb plugin [OPTIONS] COMMAND [ARGS]... + + Manage Bot Plugin. + + Options: + --help Show this message and exit. + + ... + ``` + +2. 交互式选择(支持鼠标) + + 交互式选择菜单: + + ```bash + $ nb + Welcome to NoneBot CLI! + [?] What do you want to do? (Use ↑ and ↓ to choose, Enter to submit) + ... + ``` + + 交互式子命令菜单: + + ```bash + $ nb plugin + [?] What do you want to do? (Use ↑ and ↓ to choose, Enter to submit) + ... + ```