Skip to main content

hazelnut/
lib.rs

1//! Hazelnut - Terminal-based automated file organizer
2//!
3//! A Hazel-like file organization tool with a TUI interface.
4
5pub mod app;
6pub mod config;
7pub mod ipc;
8pub mod rules;
9pub mod theme;
10pub mod watcher;
11
12pub use config::Config;
13pub use rules::{Action, Condition, Rule, RuleEngine};
14pub use theme::Theme;
15pub use watcher::Watcher;
16
17/// Expand ~ in a path to the user's home directory
18pub fn expand_path(path: &std::path::Path) -> std::path::PathBuf {
19    let path_str = path.to_string_lossy();
20
21    if let Some(stripped) = path_str.strip_prefix("~/") {
22        if let Some(home) = dirs::home_dir() {
23            return home.join(stripped);
24        }
25    } else if path_str == "~"
26        && let Some(home) = dirs::home_dir()
27    {
28        return home;
29    }
30
31    path.to_path_buf()
32}