2016-03-10 19:28:45 +00:00
|
|
|
use libimagrt::runtime::Runtime;
|
2016-05-16 16:59:02 +00:00
|
|
|
use libimagerror::trace::trace_error;
|
2016-03-13 15:50:10 +00:00
|
|
|
use libimagcounter::counter::Counter;
|
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")
|
2016-04-16 20:39:49 +00:00
|
|
|
.map(|_| {
|
2016-03-11 08:45:20 +00:00
|
|
|
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() {
|
2016-04-17 19:07:14 +00:00
|
|
|
trace_error(&name.unwrap_err());
|
2016-05-02 22:57:41 +00:00
|
|
|
} else if value.is_err() {
|
|
|
|
trace_error(&value.unwrap_err());
|
2016-03-13 15:50:10 +00:00
|
|
|
} else {
|
2016-05-02 22:57:41 +00:00
|
|
|
println!("{} - {}", name.unwrap(), value.unwrap());
|
2016-03-13 15:50:10 +00:00
|
|
|
}
|
|
|
|
})
|
2016-04-16 20:39:40 +00:00
|
|
|
.map_err(|e| trace_error(&e))
|
|
|
|
.ok();
|
2016-03-13 15:50:10 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.map_err(|e| trace_error(&e))
|
|
|
|
|
2016-03-11 08:45:20 +00:00
|
|
|
});
|
2016-03-10 19:28:45 +00:00
|
|
|
}
|