-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
29 lines (22 loc) · 902 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! This script auto-generates a man page from the clap configuration.
//! It creates the `near-facsimile.1` file in the current directory, which is
//! ignored by git.
//!
//! The code comes from the sample at <https://rust-cli.github.io/book/in-depth/docs.html>.
use clap::CommandFactory;
// We're reusing the module just for the Cli struct. Ignore the rest of the code
// and don't report it as "never used" in this build script.
#[allow(dead_code)]
#[path = "src/cli.rs"]
mod cli;
use cli::Cli;
fn main() -> std::io::Result<()> {
let out_dir =
std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?);
let cmd: clap::Command = Cli::command();
let man = clap_mangen::Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(out_dir.join("near-facsimile.1"), buffer)?;
Ok(())
}