Derive macros for click-rs CLI library.
This crate provides procedural macros for automatically generating
CommandLike implementations from Rust structs.
Example
use click_derive::Command;
#[derive(Command)]
#[command(name = "greet")]
/// A friendly greeter
struct Greet {
/// Name to greet
#[argument]
name: String,
/// Number of times to greet
#[option(short, long, default = 1)]
count: i32,
}
impl Greet {
fn run(&self, _ctx: &click::Context) -> click::Result<()> {
for _ in 0..self.count {
println!("Hello, {}!", self.name);
}
Ok(())
}
}