mirror of
https://github.com/figsoda/mmtc
synced 2024-11-14 03:37:13 +00:00
22 lines
560 B
Rust
22 lines
560 B
Rust
use clap::{ArgEnum, IntoApp};
|
|
use clap_complete::{generate_to, Shell};
|
|
|
|
use std::{env, fs::create_dir_all, path::Path};
|
|
|
|
include!("src/cli.rs");
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-env-changed=GEN_COMPLETIONS");
|
|
|
|
if env::var_os("GEN_COMPLETIONS") != Some("1".into()) {
|
|
return;
|
|
}
|
|
|
|
let out = &Path::new(&env::var_os("OUT_DIR").unwrap()).join("completions");
|
|
create_dir_all(out).unwrap();
|
|
let app = &mut Opts::command();
|
|
|
|
for shell in Shell::value_variants() {
|
|
generate_to(*shell, app, "mmtc", out).unwrap();
|
|
}
|
|
}
|