use std::env;
use std::process::ExitCode;
use scankit::{ScanConfig, Scanner};
fn main() -> ExitCode {
let Some(root) = env::args().nth(1) else {
eprintln!("usage: walk <path>");
return ExitCode::FAILURE;
};
let config = ScanConfig::default()
.max_file_size_bytes(50 * 1024 * 1024)
.add_exclude("**/.git/**")
.and_then(|c| c.add_exclude("**/node_modules/**"))
.and_then(|c| c.add_exclude("**/.DS_Store"))
.and_then(|c| c.add_exclude("**/target/**"))
.and_then(|c| c.add_exclude("**/.venv/**"))
.and_then(|c| c.add_exclude("**/__pycache__/**"));
let config = match config {
Ok(c) => c,
Err(e) => {
eprintln!("config error: {e}");
return ExitCode::FAILURE;
}
};
let scanner = match Scanner::new(config) {
Ok(s) => s,
Err(e) => {
eprintln!("scanner error: {e}");
return ExitCode::FAILURE;
}
};
let mut count: u64 = 0;
let mut total_bytes: u64 = 0;
for result in scanner.walk(&root) {
match result {
Ok(entry) => {
println!("{:>12} {}", entry.size_bytes, entry.path.display());
count += 1;
total_bytes += entry.size_bytes;
}
Err(e) => {
eprintln!("error: {e}");
}
}
}
eprintln!();
eprintln!("Scanned: {count} files, {total_bytes} bytes total");
ExitCode::SUCCESS
}