aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-11-04 10:46:16 +0100
committerAlex Auvolat <alex@adnab.me>2021-11-04 10:46:16 +0100
commit2d033eabc40f7903701dc00989ba016adb6c5f6b (patch)
treecb3dbe4322b6f48df2f39d7c2b9a7cf6694a233d
parent927a369036a6c54fb4116274c229d7647a038be4 (diff)
downloadsledcli-2d033eabc40f7903701dc00989ba016adb6c5f6b.tar.gz
sledcli-2d033eabc40f7903701dc00989ba016adb6c5f6b.zip
add total metrics to ll and lu
-rw-r--r--src/main.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 51f8f06..cca2c43 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -101,14 +101,19 @@ fn do_command(line: &str, state: &mut State) -> Result<()> {
["ll"] => {
let mut names = state.db.tree_names();
names.sort();
+ let mut total = 0;
for name in names {
let nent = state.db.open_tree(&name)?.len();
+ total += nent;
println!("{:8} {}", nent, try_string(&name));
}
+ println!("{:8} TOTAL", total);
}
["lu"] => {
let mut names = state.db.tree_names();
names.sort();
+ let mut total_nent = 0;
+ let mut total_size = 0;
for name in names {
let tree = state.db.open_tree(&name)?;
let nent = tree.len();
@@ -117,6 +122,8 @@ fn do_command(line: &str, state: &mut State) -> Result<()> {
let (k, v) = ent?;
size += k.len() + v.len();
}
+ total_nent += nent;
+ total_size += size;
println!(
"{:8} {:>12} {}",
nent,
@@ -124,6 +131,9 @@ fn do_command(line: &str, state: &mut State) -> Result<()> {
try_string(&name)
);
}
+ println!("{:8} {:>12} TOTAL",
+ total_nent,
+ total_size.file_size(file_size_opts::CONVENTIONAL).unwrap());
}
["cd", treename] => {
if state