2021-12-16 01:13:03 +01:00
|
|
|
#![allow(dead_code)]
|
2021-02-13 04:46:22 +01:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
use structopt::clap::Shell;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
2021-03-26 02:22:00 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2021-02-13 04:46:22 +01:00
|
|
|
include!("src/opt/ssh_authorizedkeys.rs");
|
|
|
|
include!("src/opt/cache_invalidate.rs");
|
|
|
|
include!("src/opt/cache_clear.rs");
|
|
|
|
include!("src/opt/unixd_status.rs");
|
|
|
|
|
|
|
|
fn main() {
|
2022-02-20 03:43:38 +01:00
|
|
|
profiles::apply_profile();
|
|
|
|
|
2021-02-13 04:46:22 +01:00
|
|
|
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()
|
2021-12-16 01:13:03 +01:00
|
|
|
.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");
|
|
|
|
}
|
|
|
|
|
2021-02-13 04:46:22 +01:00
|
|
|
SshAuthorizedOpt::clap().gen_completions(
|
|
|
|
"kanidm_ssh_authorizedkeys",
|
|
|
|
Shell::Bash,
|
2021-10-10 00:44:58 +02:00
|
|
|
comp_dir.clone(),
|
2021-02-13 04:46:22 +01:00
|
|
|
);
|
|
|
|
SshAuthorizedOpt::clap().gen_completions(
|
|
|
|
"kanidm_ssh_authorizedkeys",
|
|
|
|
Shell::Zsh,
|
2021-10-10 00:44:58 +02:00
|
|
|
comp_dir.clone(),
|
2021-02-13 04:46:22 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
CacheInvalidateOpt::clap().gen_completions(
|
|
|
|
"kanidm_cache_invalidate",
|
|
|
|
Shell::Bash,
|
2021-10-10 00:44:58 +02:00
|
|
|
comp_dir.clone(),
|
2021-02-13 04:46:22 +01:00
|
|
|
);
|
|
|
|
CacheInvalidateOpt::clap().gen_completions(
|
|
|
|
"kanidm_cache_invalidate",
|
|
|
|
Shell::Zsh,
|
2021-10-10 00:44:58 +02:00
|
|
|
comp_dir.clone(),
|
2021-02-13 04:46:22 +01:00
|
|
|
);
|
|
|
|
|
2021-10-10 00:44:58 +02:00
|
|
|
CacheClearOpt::clap().gen_completions("kanidm_cache_clear", Shell::Bash, comp_dir.clone());
|
|
|
|
CacheClearOpt::clap().gen_completions("kanidm_cache_clear", Shell::Zsh, comp_dir.clone());
|
2021-02-13 04:46:22 +01:00
|
|
|
|
2021-10-10 00:44:58 +02:00
|
|
|
UnixdStatusOpt::clap().gen_completions("kanidm_unixd_status", Shell::Bash, comp_dir.clone());
|
|
|
|
UnixdStatusOpt::clap().gen_completions("kanidm_unixd_status", Shell::Zsh, comp_dir);
|
2021-02-13 04:46:22 +01:00
|
|
|
}
|