From be07419e395cdb27607ceaa67b76a7ba25972d96 Mon Sep 17 00:00:00 2001 From: Max Bossing Date: Sat, 19 Jul 2025 17:00:42 +0200 Subject: feat: respect absolute/relative paths in dest field --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 8 ++++---- src/dots.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1b2bb4..70f66c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "dots" -version = "2.0.0" +version = "2.1.0" dependencies = [ "clap", "dirs", diff --git a/Cargo.toml b/Cargo.toml index c158254..bab7836 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dots" description = "System-agnostic dotfile-deployer " -version = "2.0.0" +version = "2.1.0" edition = "2024" [dependencies] diff --git a/README.md b/README.md index f72ae70..2f74919 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ dots_dir = "/home/anon/dots" # If omitted, defaults to working directory [[dot]] src = "nvim" # Resolved against dots_dir -dest = ".config/nvim" # Resolved against $HOME +dest = ".config/nvim" # Relative paths are resolved against $HOME [[dot]] -src = "fish" -dest = ".config/fish" +src = "Xmodmap" +dest = "/etc/X11" # Absolute paths are respected [[dot]] src = "tmux.conf" @@ -53,7 +53,7 @@ dots deploy --config some_file.dots.toml ## Todo - [x] Allow to "undeploy", eg. to automatically remove symlinks created by `dots` -- [ ] Absolute Paths in dest field +- [x] Absolute Paths in dest field ## License This is licensed under the [MIT](LICENSE) license. diff --git a/src/dots.rs b/src/dots.rs index 5b75254..0259c0c 100644 --- a/src/dots.rs +++ b/src/dots.rs @@ -8,7 +8,7 @@ pub fn deploy_dots(dots: Vec, dots_dir: PathBuf) { let prepended_dots = dots.iter().map(|m| Dot { source: dots_dir.join(&m.source), - destination: prepend_user_dir(&m.destination) + destination: if m.destination.is_absolute() { m.destination.clone() } else { prepend_user_dir(&m.destination) } } ); @@ -45,4 +45,4 @@ pub fn unlink_dots(dots: Vec, dots_dir: PathBuf) { fn prepend_user_dir(path: &PathBuf) -> PathBuf { home_dir().unwrap().join(path) -} \ No newline at end of file +} -- cgit v1.0