2021-02-17 19:16:54 +00:00
|
|
|
use clap::IntoApp;
|
|
|
|
use clap_generate::{generate_to, generators};
|
|
|
|
|
|
|
|
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();
|
|
|
|
let app = &mut Opts::into_app();
|
|
|
|
|
|
|
|
macro_rules! generate {
|
|
|
|
($($g:ident),*) => {
|
2021-08-15 01:33:22 +00:00
|
|
|
$(generate_to::<generators::$g, _, _>(app, "mmtc", out).unwrap();)*
|
2021-02-17 19:16:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
generate![Bash, Elvish, Fish, PowerShell, Zsh];
|
|
|
|
}
|