子命令 - 命令组 - 简介
您之前已经了解了如何使用 命令 创建程序。
现在我们将了解如何使用具有自身子命令的命令创建CLI 程序。也称为命令组。
例如,CLI 程序 git
有一个命令 remote
。
但 git remote
又有自己的子命令,例如 add
// git remote alone shows the current remote repositories
$ git remote
origin
// Use -v to make it verbose and show more info
$ git remote -v
origin git@github.com:yourusername/typer.git (fetch)
origin git@github.com:yourusername/typer.git (push)
// git remote add takes 2 CLI arguments, a name and URL
$ git remote add upstream https://github.com/tiangolo/typer.git
// Doesn't output anything, but now you have another remote repository called upstream
// Now check again
$ git remote -v
origin git@github.com:yourusername/typer.git (fetch)
origin git@github.com:yourusername/typer.git (push)
upstream https://github.com/tiangolo/typer.git (fetch)
upstream https://github.com/tiangolo/typer.git (push)
在接下来的部分中,我们将了解如何创建像这样的子命令。