aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2020-11-17 13:11:54 +0100
committerThomas Letan <lthms@soap.coffee>2020-11-17 13:11:54 +0100
commit0ac0ce5b4c2c602b3257d0ca244845953f8c7252 (patch)
treebf3c2715049c387dd0fab4c7e0b573a80b0b8472
parentRemove the useless “build” command (diff)
Give a more verbose output to the wc command
-rw-r--r--app/src/main.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/src/main.rs b/app/src/main.rs
index 9ea145b..3ccd06c 100644
--- a/app/src/main.rs
+++ b/app/src/main.rs
@@ -70,14 +70,28 @@ fn wc() -> Result<(), Error> {
let project : Project<_, Digest> = Project::load_and_render(&root, &loader)?;
let mut res = 0usize;
+ let mut idx = 1usize;
for c in project.chapters {
+ let mut curr = 0usize;
+
for d in c.content {
- res += d.words_count;
+ curr += d.words_count;
}
+
+ println!(
+ "{} ({})",
+ c.title
+ .map(|x| format!("{}. {}", idx, x))
+ .unwrap_or(format!("Chapter {}", idx)),
+ curr
+ );
+
+ res += curr;
+ idx += 1;
}
- println!("{}", res);
+ println!("Total: {}", res);
Ok(())
}