diff options
author | Thomas Letan <lthms@soap.coffee> | 2020-11-17 13:11:54 +0100 |
---|---|---|
committer | Thomas Letan <lthms@soap.coffee> | 2020-11-17 13:11:54 +0100 |
commit | 0ac0ce5b4c2c602b3257d0ca244845953f8c7252 (patch) | |
tree | bf3c2715049c387dd0fab4c7e0b573a80b0b8472 | |
parent | Remove the useless “build” command (diff) |
Give a more verbose output to the wc command
-rw-r--r-- | app/src/main.rs | 18 |
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(()) } |