kanidm/unix_integration/build.rs

59 lines
1.2 KiB
Rust
Raw Normal View History

#![allow(dead_code)]
use std::env;
2022-10-01 08:08:51 +02:00
use std::path::PathBuf;
2022-06-11 07:24:29 +02:00
use clap::{IntoApp, Parser};
use clap_complete::{generate_to, Shell};
include!("src/opt/ssh_authorizedkeys.rs");
2023-04-24 11:47:52 +02:00
include!("src/opt/tool.rs");
fn main() {
profiles::apply_profile();
let outdir = match env::var_os("OUT_DIR") {
None => return,
Some(outdir) => outdir,
};
2021-10-10 00:44:58 +02:00
let comp_dir = PathBuf::from(outdir)
.ancestors()
.nth(2)
2021-10-10 00:44:58 +02:00
.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");
}
2022-06-11 07:24:29 +02:00
generate_to(
Shell::Bash,
2022-06-11 07:24:29 +02:00
&mut SshAuthorizedOpt::command(),
"kanidm_ssh_authorizedkeys",
2022-06-11 07:24:29 +02:00
comp_dir.clone(),
)
.ok();
generate_to(
Shell::Zsh,
2022-06-11 07:24:29 +02:00
&mut SshAuthorizedOpt::command(),
"kanidm_ssh_authorizedkeys",
2021-10-10 00:44:58 +02:00
comp_dir.clone(),
2022-06-11 07:24:29 +02:00
)
.ok();
2022-06-11 07:24:29 +02:00
generate_to(
Shell::Zsh,
2023-04-24 11:47:52 +02:00
&mut KanidmUnixParser::command(),
"kanidm_unix",
2021-10-10 00:44:58 +02:00
comp_dir.clone(),
2022-06-11 07:24:29 +02:00
)
.ok();
generate_to(
Shell::Bash,
2023-04-24 11:47:52 +02:00
&mut KanidmUnixParser::command(),
"kanidm_unix",
comp_dir,
2022-06-11 07:24:29 +02:00
)
.ok();
}