2022-09-29 00:56:15 +00:00
|
|
|
use clap::{CommandFactory, ValueEnum};
|
2022-01-07 13:23:49 +00:00
|
|
|
use clap_complete::{generate_to, Shell};
|
2022-10-01 23:17:49 +00:00
|
|
|
use clap_mangen::Man;
|
2021-02-17 19:16:54 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
include!("src/cli.rs");
|
|
|
|
|
|
|
|
fn main() {
|
2022-10-01 23:17:49 +00:00
|
|
|
println!("cargo:rerun-if-env-changed=GEN_ARTIFACTS");
|
2021-02-17 23:48:03 +00:00
|
|
|
|
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();
|
2021-02-17 23:48:03 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|