Implement dumping
This commit is contained in:
parent
c6e9a0a4a4
commit
403965d912
2 changed files with 51 additions and 23 deletions
|
@ -17,7 +17,35 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
|
||||
use std::process::exit;
|
||||
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagerror::trace::*;
|
||||
|
||||
pub fn dump(rt: &mut Runtime) {
|
||||
unimplemented!()
|
||||
let cachingres = rt
|
||||
.store()
|
||||
.entries()
|
||||
.map_err_trace()
|
||||
.map(|iter| {
|
||||
for elem in iter {
|
||||
debug!("Working on {:?}", elem);
|
||||
if let Ok(_) = rt.store().get(elem.clone()).map_err_dbg_trace() {
|
||||
info!("Loading entry at {:?} succeeded", elem);
|
||||
} else {
|
||||
error!("Loading entry at {:?} failed", elem);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if let Ok(_) = cachingres {
|
||||
if let Err(_) = rt.store_backend_to_stdio().map_err_trace() {
|
||||
error!("Loading Store IO backend failed");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
error!("Loading entries failed");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ use libimagrt::setup::generate_runtime_setup;
|
|||
|
||||
mod create;
|
||||
mod delete;
|
||||
mod dump;
|
||||
mod error;
|
||||
mod get;
|
||||
mod retrieve;
|
||||
|
@ -55,8 +56,11 @@ mod update;
|
|||
mod verify;
|
||||
mod util;
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
use create::create;
|
||||
use delete::delete;
|
||||
use dump::dump;
|
||||
use get::get;
|
||||
use retrieve::retrieve;
|
||||
use ui::build_ui;
|
||||
|
@ -69,29 +73,25 @@ fn main() {
|
|||
"Direct interface to the store. Use with great care!",
|
||||
build_ui);
|
||||
|
||||
rt.cli()
|
||||
.subcommand_name()
|
||||
.map_or_else(
|
||||
|| {
|
||||
debug!("No command");
|
||||
let command = rt.cli().subcommand_name().map(String::from);
|
||||
|
||||
if let Some(command) = command {
|
||||
debug!("Call: {}", command);
|
||||
match command.deref() {
|
||||
"create" => create(&rt),
|
||||
"delete" => delete(&rt),
|
||||
"get" => get(&rt),
|
||||
"retrieve" => retrieve(&rt),
|
||||
"update" => update(&rt),
|
||||
"verify" => verify(&rt),
|
||||
"dump" => dump(&mut rt),
|
||||
_ => {
|
||||
debug!("Unknown command");
|
||||
// More error handling
|
||||
},
|
||||
|name| {
|
||||
debug!("Call: {}", name);
|
||||
match name {
|
||||
"create" => create(&rt),
|
||||
"delete" => delete(&rt),
|
||||
"get" => get(&rt),
|
||||
"retrieve" => retrieve(&rt),
|
||||
"update" => update(&rt),
|
||||
"verify" => verify(&rt),
|
||||
"dump" => dump(&mut rt),
|
||||
_ => {
|
||||
debug!("Unknown command");
|
||||
// More error handling
|
||||
},
|
||||
};
|
||||
}
|
||||
)
|
||||
};
|
||||
} else {
|
||||
debug!("No command");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue