Use the Parser derive macro on a struct and Subcommand on an enum to define CLI arguments, then call Cli::parse() in main to process them.
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {
Supports { renderer: String },
}
fn main() {
let cli = Cli::parse();
// Handle cli.command
}
Add clap = { version = "4", features = ["derive"] } to your Cargo.toml dependencies.