kanidm/kanidm_tools/src/cli/recycle.rs
Firstyear 6c79914395
306 command complete (#354)
Fixes #306 adding command line autocompletion. These are generated to: CARGO_TARGET_DIR/item-hash/out/. These will need to be packaged for distros later, it's unclear how we could use cargo install with these as cargo doesn't support arbitrary artefacts like this (yet?).
2021-02-13 13:46:22 +10:00

42 lines
1.3 KiB
Rust

use crate::RecycleOpt;
impl RecycleOpt {
pub fn debug(&self) -> bool {
match self {
RecycleOpt::List(copt) => copt.debug,
RecycleOpt::Get(nopt) => nopt.copt.debug,
RecycleOpt::Revive(nopt) => nopt.copt.debug,
}
}
pub fn exec(&self) {
match self {
RecycleOpt::List(copt) => {
let client = copt.to_client();
match client.recycle_bin_list() {
Ok(r) => r.iter().for_each(|e| println!("{}", e)),
Err(e) => {
eprintln!("Error -> {:?}", e);
}
}
}
RecycleOpt::Get(nopt) => {
let client = nopt.copt.to_client();
match client.recycle_bin_get(nopt.name.as_str()) {
Ok(Some(e)) => println!("{}", e),
Ok(None) => println!("No matching entries"),
Err(e) => {
eprintln!("Error -> {:?}", e);
}
}
}
RecycleOpt::Revive(nopt) => {
let client = nopt.copt.to_client();
if let Err(e) = client.recycle_bin_revive(nopt.name.as_str()) {
eprintln!("Error -> {:?}", e);
}
}
}
}
}