- Extract mover and undo functionality into dedicated modules (mover/ and undo/ subdirectories) - Move cross-platform file operations to separate file_ops.rs module for reusability - Extract batch and categorizer tests into separate test files (batch_test.rs, categorizer_test.rs) - Refactor orchestrator.rs with extracted helper functions for improved readability - Separate cache and undo log initialization - Extract path resolution and offline mode determination logic - Simplify main organization flow by delegating to helper functions - Update module exports to expose new types and functions (MoveError, MoveSummary, UndoError, UndoSummary) - Reduce code duplication of move_file_cross_platform implementation
44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
use crate::models::FileCategory;
|
|
use colored::*;
|
|
use std::path::MAIN_SEPARATOR;
|
|
|
|
pub(super) fn display_plan(files: &[FileCategory]) {
|
|
println!("\n{}", "--- EXECUTION PLAN ---".bold().underline());
|
|
|
|
if files.is_empty() {
|
|
println!("{}", "No files to organize.".yellow());
|
|
return;
|
|
}
|
|
|
|
for item in files {
|
|
let target_display = format_target_path(&item.category, &item.sub_category);
|
|
println!(
|
|
"Plan: {} -> {}{}",
|
|
item.filename, target_display, MAIN_SEPARATOR
|
|
);
|
|
}
|
|
}
|
|
|
|
pub(super) fn print_summary(summary: &super::types::MoveSummary) {
|
|
println!("\n{}", "Organization Complete!".bold().green());
|
|
println!(
|
|
"Files moved: {}, Errors: {}",
|
|
summary.moved_count().to_string().green(),
|
|
summary.error_count().to_string().red()
|
|
);
|
|
}
|
|
|
|
pub(super) fn format_target_path(category: &str, sub_category: &str) -> String {
|
|
let target_display = format!("{}", category.green());
|
|
if sub_category.is_empty() {
|
|
target_display
|
|
} else {
|
|
format!(
|
|
"{}{}{}",
|
|
target_display,
|
|
MAIN_SEPARATOR,
|
|
sub_category.blue()
|
|
)
|
|
}
|
|
}
|