16 releases

Uses new Rust 2021

new 0.2.2 Sep 29, 2022
0.2.1 Sep 28, 2022
0.1.11 Aug 31, 2022
0.1.10 Jun 28, 2022
0.1.2 Feb 16, 2022

#76 in Command-line interface

Download history 3959/week @ 2022-06-11 2617/week @ 2022-06-18 3478/week @ 2022-06-25 1959/week @ 2022-07-02 2208/week @ 2022-07-09 3174/week @ 2022-07-16 1952/week @ 2022-07-23 3345/week @ 2022-07-30 3376/week @ 2022-08-06 4635/week @ 2022-08-13 3176/week @ 2022-08-20 4005/week @ 2022-08-27 3977/week @ 2022-09-03 5599/week @ 2022-09-10 4385/week @ 2022-09-17 3224/week @ 2022-09-24

17,743 downloads per month
Used in 28 crates (26 directly)

MIT/Apache

1MB
15K SLoC

clap_mangen

Manpage generation for clap

Crates.io Crates.io License License

Dual-licensed under Apache 2.0 or MIT.

  1. About
  2. API Reference
  3. Questions & Discussions
  4. CONTRIBUTING
  5. Sponsors

About

Generate ROFF from a clap::Command.

Example

We're going to assume you want to generate your man page as part of your development rather than your shipped program having a flag to generate it.

In your Cargo.toml:

[build-dependencies]
clap_mangen = "0.1"

In your build.rs:

fn main() -> std::io::Result<()> {
    let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?);

    let cmd = clap::Command::new("mybin")
        .arg(clap::arg!(-n --name <NAME>))
        .arg(clap::arg!(-c --count <NUM>));

    let man = clap_mangen::Man::new(cmd);
    let mut buffer: Vec<u8> = Default::default();
    man.render(&mut buffer)?;

    std::fs::write(out_dir.join("mybin.1"), buffer)?;

    Ok(())
}

Tip: Consider a cargo xtask instead of a build.rs to reduce build costs.

Dependencies

~130–790KB
~16K SLoC