imag/imag-counter/src/list.rs

36 lines
1.1 KiB
Rust
Raw Normal View History

2016-03-10 19:28:45 +00:00
use libimagrt::runtime::Runtime;
2016-03-13 15:50:10 +00:00
use libimagutil::trace::trace_error;
use libimagcounter::counter::Counter;
use libimagcounter::result::Result;
2016-03-10 19:28:45 +00:00
pub fn list(rt: &Runtime) {
2016-03-11 08:45:20 +00:00
rt.cli()
.subcommand_matches("list")
.map(|scmd| {
debug!("Found 'list' subcommand...");
2016-03-13 15:50:10 +00:00
Counter::all_counters(rt.store()).map(|iterator| {
for counter in iterator {
counter.map(|c| {
let name = c.name();
let value = c.value();
if name.is_err() {
trace_error(&name.err().unwrap());
} else {
if value.is_err() {
trace_error(&value.err().unwrap());
} else {
println!("{} - {}", name.unwrap(), value.unwrap());
}
}
})
.map_err(|e| trace_error(&e));
}
})
.map_err(|e| trace_error(&e))
2016-03-11 08:45:20 +00:00
});
2016-03-10 19:28:45 +00:00
}