git, docker, and npm.
When to Use Multi-Command Pattern
Use this pattern when your CLI:- Provides multiple related operations
- Needs a clean namespace for different actions
- Benefits from command-specific help
git commit, docker build, npm install
Creating a Router CLI
Command Organization
Each command is self-contained with its own args, options, and handler:Help Text Generation
Help is automatically generated for the router and each command.Router Help
Command-Specific Help
Multiple Arguments Per Command
Each command can have its own argument schema:Complete Multi-Command Example
Here’s a complete package manager CLI:Usage Examples
Type Safety
All arguments and options are fully typed:The
.command() method returns the same CLI instance, so you can chain as many commands as you need. The type system tracks all registered commands for features like CTAs.
