use super::*; use lazy_static::lazy_static; #[cfg(feature="threads")] use std::num::NonZeroUsize; #[derive(Debug, Clone)] pub enum RecursionMode { None, All, N(usize), } #[derive(Debug, Clone)] pub enum OperationMode { Print, Delete, } #[derive(Debug, Clone)] pub struct Mode { pub error_mode: error::Mode, pub recursion_mode: RecursionMode, pub operation_mode: OperationMode, pub logging_mode: log::Mode, } impl Default for Mode { fn default() -> Self { Self { error_mode: error::Mode::Cancel, recursion_mode: RecursionMode::None, operation_mode: OperationMode::Print, logging_mode: log::Mode::Warn, } } } lazy_static! { pub static ref DEFAULT_HASHNAME: &'static str = { let string = expand_path(DEFAULT_HASHNAME_STRING); Box::leak(string.into_boxed_str()) }; } const DEFAULT_HASHNAME_STRING: &'static str = "~/.rmdupe"; /// Expand path for shell fn expand_path(path: impl AsRef) -> String { shellexpand::tilde(path.as_ref()).to_string() } /// Default max threads, `None` for unlimited. #[cfg(feature="threads")] pub const MAX_THREADS: Option = Some(unsafe{NonZeroUsize::new_unchecked(10)}); #[derive(Debug)] pub struct Config { /// Paths to dupde-check pub paths: Vec, /// operation mode pub mode: Mode, /// Save hashes to pub save: Vec, /// Load hashes from pub load: Vec, /// Max number of threads to spawn #[cfg(feature="threads")] pub max_threads: Option, //TODO: Implement } #[derive(Debug)] pub struct Rebase { /// Load from here pub load: Vec, /// Rebase to here pub save: Vec, /// Max number of threads to spawn #[cfg(feature="threads")] pub max_threads: Option, //TODO: Implement }