Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
examples/ | 12-May-2024 | - | 39 | 33 | ||
src/ | 12-May-2024 | - | 624 | 489 | ||
tests/ | 12-May-2024 | - | 786 | 726 | ||
CHANGELOG.md | D | 12-May-2024 | 2.8 KiB | 94 | 59 | |
CONTRIBUTING.md | D | 12-May-2024 | 126 | 4 | 2 | |
Cargo.toml | D | 12-May-2024 | 1.5 KiB | 45 | 38 | |
LICENSE-APACHE | D | 12-May-2024 | 11.1 KiB | 202 | 169 | |
LICENSE-MIT | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
README.md | D | 12-May-2024 | 1.9 KiB | 54 | 37 |
README.md
1<!-- omit in TOC --> 2# clap_mangen 3 4> **Manpage generation for `clap`** 5 6[](https://crates.io/crates/clap_mangen) 7[](https://crates.io/crates/clap_mangen) 8[](https://github.com/clap-rs/clap/blob/clap_mangen-v0.2.7/LICENSE-APACHE) 9[](https://github.com/clap-rs/clap/blob/clap_mangen-v0.2.7/LICENSE-MIT) 10 11Dual-licensed under [Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT). 12 131. [About](#about) 142. [API Reference](https://docs.rs/clap_mangen) 153. [Questions & Discussions](https://github.com/clap-rs/clap/discussions) 164. [CONTRIBUTING](https://github.com/clap-rs/clap/blob/clap_mangen-v0.2.7/clap_mangen/CONTRIBUTING.md) 175. [Sponsors](https://github.com/clap-rs/clap/blob/clap_mangen-v0.2.7/README.md#sponsors) 18 19## About 20 21Generate [ROFF](https://en.wikipedia.org/wiki/Roff_(software)) from a `clap::Command`. 22 23### Example 24 25We're going to assume you want to generate your man page as part of your 26development rather than your shipped program having a flag to generate it. 27 28In your `Cargo.toml`: 29```toml 30[build-dependencies] 31clap_mangen = "0.1" 32``` 33 34In your `build.rs`: 35```rust,no_run 36fn main() -> std::io::Result<()> { 37 let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?); 38 39 let cmd = clap::Command::new("mybin") 40 .arg(clap::arg!(-n --name <NAME>)) 41 .arg(clap::arg!(-c --count <NUM>)); 42 43 let man = clap_mangen::Man::new(cmd); 44 let mut buffer: Vec<u8> = Default::default(); 45 man.render(&mut buffer)?; 46 47 std::fs::write(out_dir.join("mybin.1"), buffer)?; 48 49 Ok(()) 50} 51``` 52 53Tip: Consider a [cargo xtask](https://github.com/matklad/cargo-xtask) instead of a `build.rs` to reduce build costs. 54