Skip to main content

fren_date/
opts.rs

1//! Option structs for the `fren` library entry points.
2
3use crate::SlugOpts;
4use std::path::PathBuf;
5
6/// Conflict resolution policy when a rename target already exists or two
7/// plans target the same path.
8///
9/// Currently only [`ConflictPolicy::Abort`] is functional; the other
10/// variants are reserved for future expansion and are accepted by the
11/// type but not yet implemented in the planner/executor.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13pub enum ConflictPolicy {
14    /// Stop the batch on conflict. No I/O is performed when a conflict is
15    /// detected at planning time.
16    #[default]
17    Abort,
18    /// Append the user separator + an integer to the target name until a
19    /// free name is found.
20    Number,
21    /// Skip just the conflicting plan; continue the batch.
22    Skip,
23    /// For directory-vs-directory conflicts, recursively merge contents
24    /// (file conflicts inside fall back to `Number`). For file-vs-file
25    /// conflicts, behaves like `Abort`.
26    Merge,
27}
28
29/// Options for planning a rename batch.
30#[derive(Debug, Clone, Default)]
31pub struct PlanOpts {
32    /// Paths to exclude.
33    pub exclude: Vec<PathBuf>,
34    /// Whether to traverse subdirectories.
35    pub recursive: bool,
36    /// What to do on conflicts. Currently only `Abort` is functional.
37    pub on_conflict: ConflictPolicy,
38}
39
40/// Top-level options for `fren::rename` (the high-level convenience entry).
41#[derive(Debug, Clone, Default)]
42pub struct RenameOpts {
43    /// Slugify options (separator, case).
44    pub slugify: SlugOpts,
45    /// Planning options (recursion, exclusion, conflict policy).
46    pub plan: PlanOpts,
47    /// `true` to actually execute the renames; `false` for dry-run (default).
48    pub apply: bool,
49}