mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-24 13:07:00 +01:00
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?).
42 lines
1.3 KiB
Rust
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|