Implement dumping

This commit is contained in:
Matthias Beyer 2017-06-18 20:00:47 +02:00
parent c6e9a0a4a4
commit 403965d912
2 changed files with 51 additions and 23 deletions

View file

@ -17,7 +17,35 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 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) { 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);
}
} }

View file

@ -47,6 +47,7 @@ use libimagrt::setup::generate_runtime_setup;
mod create; mod create;
mod delete; mod delete;
mod dump;
mod error; mod error;
mod get; mod get;
mod retrieve; mod retrieve;
@ -55,8 +56,11 @@ mod update;
mod verify; mod verify;
mod util; mod util;
use std::ops::Deref;
use create::create; use create::create;
use delete::delete; use delete::delete;
use dump::dump;
use get::get; use get::get;
use retrieve::retrieve; use retrieve::retrieve;
use ui::build_ui; use ui::build_ui;
@ -69,16 +73,11 @@ fn main() {
"Direct interface to the store. Use with great care!", "Direct interface to the store. Use with great care!",
build_ui); build_ui);
rt.cli() let command = rt.cli().subcommand_name().map(String::from);
.subcommand_name()
.map_or_else( if let Some(command) = command {
|| { debug!("Call: {}", command);
debug!("No command"); match command.deref() {
// More error handling
},
|name| {
debug!("Call: {}", name);
match name {
"create" => create(&rt), "create" => create(&rt),
"delete" => delete(&rt), "delete" => delete(&rt),
"get" => get(&rt), "get" => get(&rt),
@ -91,7 +90,8 @@ fn main() {
// More error handling // More error handling
}, },
}; };
} else {
debug!("No command");
} }
)
} }