4 releases (2 stable)

2.0.3 Jan 10, 2025
1.0.0 Dec 9, 2024
0.2.0 Nov 4, 2024
0.1.0 Aug 13, 2023

#711 in Development tools

Download history 1/week @ 2024-09-25 2/week @ 2024-10-09 2/week @ 2024-10-16 134/week @ 2024-10-30 221/week @ 2024-11-06 163/week @ 2024-11-13 63/week @ 2024-11-20 17/week @ 2024-11-27 188/week @ 2024-12-04 152/week @ 2024-12-11 50/week @ 2024-12-18 5/week @ 2024-12-25 10/week @ 2025-01-01 183/week @ 2025-01-08

254 downloads per month
Used in 3 crates

MIT license

150KB
4K SLoC

clap_usage

Generates usage spec for CLIs written with clap.

Usage

use clap::{arg, Command, ValueHint};
use clap_usage::generate;
use std::io::BufWriter;

fn build_cli() -> Command {
    Command::new("example")
        .arg(arg!(--file <FILE> "some input file").value_hint(ValueHint::AnyPath))
        .arg(arg!(--usage))
}

fn main() {
    let matches = build_cli().get_matches();

    if matches.get_flag("usage") {
        let mut cmd = build_cli();
        eprintln!("Generating usage spec...");
        clap_usage::generate(&mut cmd, "example", &mut std::io::stdout()).unwrap();
        return;
    }

    // Your CLI code here...
}

Dependencies

~10–37MB
~548K SLoC