mmtc/build.rs

30 lines
687 B
Rust
Raw Normal View History

2022-10-01 23:17:49 +00:00
use std::{
env,
fs::{create_dir_all, File},
path::Path,
};
2021-02-17 19:16:54 +00:00
2023-07-01 20:44:29 +00:00
use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use clap_mangen::Man;
2021-02-17 19:16:54 +00:00
include!("src/cli.rs");
fn main() {
2022-10-01 23:17:49 +00:00
println!("cargo:rerun-if-env-changed=GEN_ARTIFACTS");
2022-10-01 23:17:49 +00:00
if let Some(dir) = env::var_os("GEN_ARTIFACTS") {
let out = &Path::new(&dir);
create_dir_all(out).unwrap();
let cmd = &mut Opts::command();
2022-10-01 23:17:49 +00:00
Man::new(cmd.clone())
.render(&mut File::create(out.join("mmtc.1")).unwrap())
.unwrap();
2021-02-17 19:16:54 +00:00
2022-10-01 23:17:49 +00:00
for shell in Shell::value_variants() {
generate_to(*shell, cmd, "mmtc", out).unwrap();
}
2021-02-17 19:16:54 +00:00
}
}