Skip to content

Commit 6a067a5

Browse files
committed
Add calculation of total size in main with upgraded styling
1 parent bdedd65 commit 6a067a5

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use clap::Parser;
22
use console::{style, Term};
33
use crufty::cli::{Cli, Commands};
4-
use crufty::estimator::estimate;
4+
use crufty::estimator::{estimate, total_size};
55
use crufty::fetcher::fetch_artifacts;
6-
use crufty::types::Size;
7-
use crufty::ui;
6+
use crufty::ui::{self, style_size};
87
use std::env;
98
use std::io;
109
use std::process;
@@ -46,25 +45,26 @@ fn scan() -> io::Result<()> {
4645
for (i, artifact) in artifacts.iter().enumerate() {
4746
let rel_path =
4847
artifact.path.strip_prefix(&path).unwrap_or(&artifact.path);
49-
let size_display = match &artifact.size {
50-
Size::UnknownSize => style(format!("{}", artifact.size)).yellow(),
51-
Size::KnownSize(_) => style(format!("{}", artifact.size)).green(),
52-
};
5348

5449
term.write_line(&format!(
55-
"[{}] {:<30} {}",
50+
"[{}] {:<36} {}",
5651
i + 1,
5752
style(format!("./{}", rel_path.display())).bold(),
58-
size_display
53+
style_size(&artifact.size)
5954
))?;
6055
}
6156

57+
let total = total_size(&artifacts);
58+
6259
term.write_line("")?;
6360
term.write_line(&format!(
64-
"{} Scan completed successfully",
65-
style("✓").green()
61+
"Total size: {} in {} directories",
62+
style_size(&total),
63+
style(format!("{}", artifacts.len())).bold()
6664
))?;
6765

66+
term.write_line("Use `crafty clean` to remove these safely")?;
67+
6868
Ok(())
6969
}
7070
}

0 commit comments

Comments
 (0)