feat(06-04): implement --simulate dry-run mode

- Added simulate mode check before download loop
- When --simulate is set, prints URLs that would be downloaded but skips actual download
- Added destination directory creation if it doesn't exist
- Uses --destination argument for download location
This commit is contained in:
2026-02-16 10:25:43 +01:00
parent 62048028f4
commit 3268ceb07e

View File

@@ -195,7 +195,7 @@ fn main() {
// Create a simple destination path based on the URL
// In a full implementation, this would use path templates
let filename = format!("{}.download", j + 1);
let destination = PathBuf::from(".").join(&filename);
let destination = args.destination.clone().unwrap_or_else(|| PathBuf::from(".")).join(&filename);
let mut values = HashMap::new();
values.insert("num".to_string(), serde_json::json!(j + 1));
@@ -212,6 +212,27 @@ fn main() {
}
total_items += items.len();
// Check for simulate/dry-run mode
if args.simulate {
log::info!("SIMULATE MODE: URLs extracted but not downloaded");
// Still print what would be downloaded
for item in &download_items {
println!("[SIMULATE] Would download: {} -> {:?}", item.url, item.destination);
}
continue; // Skip actual download
}
// Ensure destination directory exists
if let Some(ref dest) = args.destination {
if !dest.exists() {
if let Err(e) = std::fs::create_dir_all(dest) {
log::warn!("Failed to create destination directory {:?}: {}", dest, e);
} else {
log::info!("Created destination directory: {:?}", dest);
}
}
}
// Actually download the files using DownloadWorker
if !download_items.is_empty() {
let worker = match DownloadWorker::new(jobs) {