clap_usage

Crates.ioclap_usage
lib.rsclap_usage
version
sourcesrc
created_at2023-08-13 01:34:23.071157
updated_at2024-11-04 22:49:33.995607
descriptionLibrary for working with usage specs
homepagehttps://usage.jdx.dev
repositoryhttps://github.com/jdx/usage
max_upload_size
id943090
Cargo.toml error:TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(jdx)

documentation

https://usage.jdx.dev

README

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::stderr()).unwrap();
        return;
    }

    // Your CLI code here...
}
Commit count: 315

cargo fmt