| 179 | Ok(()) |
| 180 | } |
| 181 | fn main() -> Result<()> { |
| 182 | let source = std::env::args() |
| 183 | .nth(1) |
| 184 | .context("usage: semantic_storage <change-file-or-directory>")?; |
| 185 | let mut paths = vec![]; |
| 186 | collect(Path::new(&source), &mut paths)?; |
| 187 | paths.sort(); |
| 188 | ensure!(!paths.is_empty(), "no change files"); |
| 189 | let mut totals = Sizes::default(); |
| 190 | let mut rows = vec![]; |
| 191 | let mut failures = vec![]; |
| 192 | for path in paths { |
| 193 | match measure(&path).with_context(|| path.display().to_string()) { |
| 194 | Ok(row) => { |
| 195 | eprintln!( |
| 196 | "{}: {} -> {} bytes", |
| 197 | path.display(), |
| 198 | row.sizes.raw_bytes, |
| 199 | row.sizes.selected_bytes |
| 200 | ); |
| 201 | totals.add(&row.sizes); |
| 202 | rows.push(row); |
| 203 | } |
| 204 | Err(error) => { |
| 205 | eprintln!("{error:#}"); |
| 206 | failures.push(format!("{error:#}")); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | println!( |
| 211 | "{}", |
| 212 | serde_json::to_string_pretty(&serde_json::json!({"zstd_level":3, |
| 213 | "comparison":"new unsigned canonical raw vs adaptive objects; historical files untouched; not a Git-pack comparison", |
| 214 | "totals":totals,"rows":rows,"failures":failures}))? |
| 215 | ); |
| 216 | ensure!( |
| 217 | failures.is_empty(), |
| 218 | "input failures; totals cover only successful inputs" |
| 219 | ); |
| 220 | Ok(()) |
| 221 | } |