-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
35 lines (27 loc) · 837 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
30
31
32
33
34
35
use clap::ValueEnum;
use clap_complete::{generate_to, Shell};
use clap_mangen::Man;
use std::env;
use std::fs::File;
use std::io::Error;
use std::path::PathBuf;
include!("src/cli/command.rs");
fn main() -> Result<(), Error> {
let real_outdir = match env::var_os("OUT_DIR") {
None => return Ok(()),
Some(outdir) => outdir,
};
let outdir = match env::var_os("MAN_OUT") {
None => real_outdir,
Some(outdir) => outdir,
};
let mut cmd = build_cli();
for &shell in Shell::value_variants() {
generate_to(shell, &mut cmd, "powertest", &outdir)?;
}
let file = PathBuf::from(&outdir).join("powertest.1");
let mut file = File::create(file)?;
Man::new(cmd).render(&mut file)?;
println!("cargo:warning=completion file is generated: {outdir:?}");
Ok(())
}