|
1 | 1 | use clap::Parser; |
2 | 2 | use console::{style, Term}; |
3 | 3 | use crufty::cli::{Cli, Commands}; |
4 | | -use crufty::estimator::estimate; |
| 4 | +use crufty::estimator::{estimate, total_size}; |
5 | 5 | use crufty::fetcher::fetch_artifacts; |
6 | | -use crufty::types::Size; |
7 | | -use crufty::ui; |
| 6 | +use crufty::ui::{self, style_size}; |
8 | 7 | use std::env; |
9 | 8 | use std::io; |
10 | 9 | use std::process; |
@@ -46,25 +45,26 @@ fn scan() -> io::Result<()> { |
46 | 45 | for (i, artifact) in artifacts.iter().enumerate() { |
47 | 46 | let rel_path = |
48 | 47 | 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 | | - }; |
53 | 48 |
|
54 | 49 | term.write_line(&format!( |
55 | | - "[{}] {:<30} {}", |
| 50 | + "[{}] {:<36} {}", |
56 | 51 | i + 1, |
57 | 52 | style(format!("./{}", rel_path.display())).bold(), |
58 | | - size_display |
| 53 | + style_size(&artifact.size) |
59 | 54 | ))?; |
60 | 55 | } |
61 | 56 |
|
| 57 | + let total = total_size(&artifacts); |
| 58 | + |
62 | 59 | term.write_line("")?; |
63 | 60 | 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() |
66 | 64 | ))?; |
67 | 65 |
|
| 66 | + term.write_line("Use `crafty clean` to remove these safely")?; |
| 67 | + |
68 | 68 | Ok(()) |
69 | 69 | } |
70 | 70 | } |
|
0 commit comments