# Example: CLI subcommand
## Using Marketplace Rpack (Recommended)
### 1. Search and Install
```bash
# Search for CLI subcommand rpacks
rgen search rust cli
# Install the rpack
rgen add io.rgen.rust.cli-subcommand
```
### 2. Generate Code
```bash
# Generate using the rpack template
rgen gen io.rgen.rust.cli-subcommand:cli/subcommand/rust.tmpl name=status description="Show application status"
```
### 3. Verify Output
```bash
# Check generated file
cat src/cmds/status.rs
```
Output:
```rust
// Generated by rpack: io.rgen.rust.cli-subcommand
// Template: cli/subcommand/rust.tmpl
use clap::Parser;
#[derive(Parser)]
pub struct StatusArgs {
/// Show application status
#[arg(short, long)]
pub verbose: bool,
}
pub fn status(args: StatusArgs) -> Result<(), Box<dyn std::error::Error>> {
println!("Application status: Running");
if args.verbose {
println!("Detailed status information...");
}
Ok(())
}
```
## Using Local Template (Advanced)
Create `templates/cli/subcommand/rust.tmpl` (see quickstart for full template).
Generate:
```bash
rgen gen cli subcommand --vars cmd=status summary="Show status"
```
Outputs:
```
src/cmds/status.rs
```
## Comparison
| **Marketplace** | Instant | Community tested | Automatic | Most users |
| **Local** | Manual | Custom | Manual | Special needs |
## Next Steps
- Try the [multi-language example](cli-subcommand-multi.md)
- Explore [marketplace rpacks](marketplace.md)
- Learn about [template development](templates.md)