click-derive 1.0.0

Derive macros for click-rs CLI library
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 121.18 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 648.31 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mrsaraiva/click-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mrsaraiva

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(())
    }
}