Appearance
Clap
A simple to use, efficient, and full-featured Command Line Argument Parser for Rust
Overview
Clap is a command-line argument parser for Rust that helps you parse command-line arguments by defining a struct, enum, or slice.
Features
- Declarative API
- Derive macros
- Argument parsing
- Help generation
- Shell completion
- Validation
- Custom error messages
Getting Started
toml
# Cargo.toml
[dependencies]
clap = { version = "4.0", features = ["derive"] }Basic Example
rust
use clap::Parser;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Name of the person to greet
#[arg(short, long)]
name: String,
/// Number of times to greet
#[arg(short, long, default_value_t = 1)]
count: u8,
}
fn main() {
let cli = Cli::parse();
for _ in 0..cli.count {
println!("Hello {}!", cli.name);
}
}PAPER-CODE Integration
PAPER-CODE provides:
- Clap project templates
- CLI structure patterns
- Testing configurations
- Cargo workspace setup