SubCommands - Command Groups - Intro
You read before how to create a program with Commands.
Now we'll see how to create a CLI program with commands that have their own subcommands. Also known as command groups.
For example, the CLI program git
has a command remote
.
But git remote
, in turn, has its own subcommands, like add
:
💬 git remote alone shows the current remote repositoriesgit remote
origin
💬 Use -v to make it verbose and show more infogit remote -v
origin git@github.com:yourusername/typer-cloup.git (fetch)
origin git@github.com:yourusername/typer-cloup.git (push)
💬 git remote add takes 2 CLI arguments, a name and URLgit remote add upstream https://github.com/alexreg/typer-cloup.git
💬 Doesn't output anything, but now you have another remote repository called upstream
💬 Now check againgit remote -v
origin git@github.com:yourusername/typer-cloup.git (fetch)
origin git@github.com:yourusername/typer-cloup.git (push)
upstream https://github.com/alexreg/typer-cloup.git (fetch)
upstream https://github.com/alexreg/typer-cloup.git (push)
restart ↻
origin
💬 Use -v to make it verbose and show more infogit remote -v
origin git@github.com:yourusername/typer-cloup.git (fetch)
origin git@github.com:yourusername/typer-cloup.git (push)
💬 git remote add takes 2 CLI arguments, a name and URLgit remote add upstream https://github.com/alexreg/typer-cloup.git
💬 Doesn't output anything, but now you have another remote repository called upstream
💬 Now check againgit remote -v
origin git@github.com:yourusername/typer-cloup.git (fetch)
origin git@github.com:yourusername/typer-cloup.git (push)
upstream https://github.com/alexreg/typer-cloup.git (fetch)
upstream https://github.com/alexreg/typer-cloup.git (push)
restart ↻
In the next sections we'll see how to create subcommands like these.