kanidm/tools/cli/build.rs
Firstyear cccc20ea42
20230731 release (#1921)
* Cleanup how we check for last git commit to avoid an insecure dep
* Resolve unmaintained or old deps
* Fix ci
2023-07-31 22:27:21 +10:00

62 lines
1.3 KiB
Rust

#![allow(dead_code)]
use std::env;
use std::path::PathBuf;
use clap::{CommandFactory, Parser};
use clap_complete::{generate_to, Shell};
use url::Url;
use uuid::Uuid;
include!("src/opt/ssh_authorizedkeys.rs");
include!("src/opt/kanidm.rs");
fn main() {
profiles::apply_profile();
let outdir = match env::var_os("OUT_DIR") {
None => return,
Some(outdir) => outdir,
};
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");
}
generate_to(
Shell::Bash,
&mut SshAuthorizedOpt::command(),
"kanidm_ssh_authorizedkeys_direct",
comp_dir.clone(),
)
.ok();
generate_to(
Shell::Zsh,
&mut SshAuthorizedOpt::command(),
"kanidm_ssh_authorizedkeys_direct",
comp_dir.clone(),
)
.ok();
generate_to(
Shell::Bash,
&mut KanidmClientParser::command(),
"kanidm",
comp_dir.clone(),
)
.ok();
generate_to(
Shell::Zsh,
&mut KanidmClientParser::command(),
"kanidm",
comp_dir,
)
.ok();
}