2021-10-18 12:29:45 +00:00
|
|
|
use clap::{ArgEnum, IntoApp};
|
2022-01-07 13:23:49 +00:00
|
|
|
use clap_complete::{generate_to, Shell};
|
2021-02-17 19:16:54 +00:00
|
|
|
|
|
|
|
use std::{env, fs::create_dir_all, path::Path};
|
|
|
|
|
|
|
|
include!("src/cli.rs");
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-17 23:48:03 +00:00
|
|
|
println!("cargo:rerun-if-env-changed=GEN_COMPLETIONS");
|
|
|
|
|
|
|
|
if env::var_os("GEN_COMPLETIONS") != Some("1".into()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-17 19:16:54 +00:00
|
|
|
let out = &Path::new(&env::var_os("OUT_DIR").unwrap()).join("completions");
|
|
|
|
create_dir_all(out).unwrap();
|
2022-05-04 16:16:44 +00:00
|
|
|
let app = &mut Opts::command();
|
2021-02-17 19:16:54 +00:00
|
|
|
|
2021-10-18 12:29:45 +00:00
|
|
|
for shell in Shell::value_variants() {
|
|
|
|
generate_to(*shell, app, "mmtc", out).unwrap();
|
2021-02-17 19:16:54 +00:00
|
|
|
}
|
|
|
|
}
|