use crate::config::DryRunMode;
use crate::filter::{FilterResult, TimeSkipReason};
pub fn report_action(
verb: &str,
src: &std::path::Path,
dst: Option<&std::path::Path>,
entry_type: &str,
) {
match dst {
Some(dst) => println!("would {} {} {:?} -> {:?}", verb, entry_type, src, dst),
None => println!("would {} {} {:?}", verb, entry_type, src),
}
}
pub fn report_skip(
path: &std::path::Path,
result: &FilterResult,
mode: DryRunMode,
entry_type: &str,
) {
match mode {
DryRunMode::Brief => { }
DryRunMode::All => {
println!("skip {} {:?}", entry_type, path);
}
DryRunMode::Explain => match result {
FilterResult::ExcludedByDefault => {
println!(
"skip {} {:?} (no include pattern matched)",
entry_type, path
);
}
FilterResult::ExcludedByPattern(pattern) => {
println!("skip {} {:?} (excluded by '{}')", entry_type, path, pattern);
}
FilterResult::Included => { }
},
}
}
pub fn format_skip_reason(result: &FilterResult) -> Option<String> {
match result {
FilterResult::Included => None,
FilterResult::ExcludedByDefault => Some("no include pattern matched".to_string()),
FilterResult::ExcludedByPattern(p) => Some(format!("excluded by '{}'", p)),
}
}
pub fn report_time_skip(
path: &std::path::Path,
reason: TimeSkipReason,
mode: DryRunMode,
entry_type: &str,
) {
match mode {
DryRunMode::Brief => { }
DryRunMode::All => {
println!("skip {} {:?}", entry_type, path);
}
DryRunMode::Explain => {
let reason_str = match reason {
TimeSkipReason::TooNewModified => "mtime is too recent",
TimeSkipReason::TooNewCreated => "btime is too recent",
TimeSkipReason::TooNewBoth => "mtime and btime are too recent",
};
println!("skip {} {:?} ({})", entry_type, path, reason_str);
}
}
}