forked from sirwart/ripsecrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
26 lines (20 loc) · 857 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
include!("src/args.rs");
fn main() -> std::io::Result<()> {
// Tell Cargo that if the given file changes, to rerun this build script.
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/args.rs");
let out_dir =
std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?);
let cmd = <Args as clap::CommandFactory>::command();
// Generate man page
let man = clap_mangen::Man::new(cmd.clone());
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;
std::fs::write(out_dir.join("ripsecrets.1"), buffer)?;
// Generate shell completions
use clap::ValueEnum;
for shell in clap_complete::Shell::value_variants() {
clap_complete::generate_to(*shell, &mut cmd.clone(), "ripsecrets", &out_dir)?;
}
Ok(())
}