2022-02-20 03:43:38 +01:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
use std::path::PathBuf;
|
2022-06-11 07:24:29 +02:00
|
|
|
|
2023-07-13 04:19:28 +02:00
|
|
|
use clap::{Args, CommandFactory, Parser, Subcommand};
|
2022-06-11 07:24:29 +02:00
|
|
|
use clap_complete::{generate_to, Shell};
|
2022-02-20 03:43:38 +01:00
|
|
|
|
|
|
|
include!("src/opt.rs");
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
profiles::apply_profile();
|
|
|
|
|
2024-02-27 10:25:02 +01:00
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
println!("cargo:rerun-if-env-changed=OUT_DIR");
|
|
|
|
println!("cargo:rerun-if-changed=src/opt.rs");
|
2022-02-20 03:43:38 +01:00
|
|
|
let outdir = match env::var_os("OUT_DIR") {
|
|
|
|
None => return,
|
|
|
|
Some(outdir) => outdir,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Will be the form /Volumes/ramdisk/rs/debug/build/kanidm-8aadc4b0821e9fe7/out
|
|
|
|
// We want to get to /Volumes/ramdisk/rs/debug/completions
|
|
|
|
let comp_dir = PathBuf::from(outdir)
|
|
|
|
.ancestors()
|
|
|
|
.nth(2)
|
|
|
|
.map(|p| p.join("completions"))
|
|
|
|
.expect("Unable to process completions path");
|
|
|
|
|
|
|
|
if !comp_dir.exists() {
|
|
|
|
std::fs::create_dir(&comp_dir).expect("Unable to create completions dir");
|
|
|
|
}
|
|
|
|
|
2024-09-04 01:50:59 +02:00
|
|
|
for shell in [Shell::Bash, Shell::Elvish, Shell::Fish, Shell::Zsh] {
|
|
|
|
generate_to(
|
|
|
|
shell,
|
|
|
|
&mut KanidmdParser::command(),
|
|
|
|
"kanidmd",
|
|
|
|
comp_dir.clone(),
|
|
|
|
)
|
|
|
|
.ok();
|
|
|
|
}
|
2022-02-20 03:43:38 +01:00
|
|
|
}
|