aboutsummaryrefslogtreecommitdiff
path: root/src/dotup.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2022-02-15 19:16:27 +0000
committerdiogo464 <[email protected]>2022-02-15 19:16:27 +0000
commit80bcbb07c92ebe737376ecfb867917c8324d77d8 (patch)
tree1c62926a0a04df045e1fb46d9a32c428c4a0180d /src/dotup.rs
parent2b04d646aec90e0fe28e84356b13758b8a956e8a (diff)
improved link command
if the destination path ends with a slash then it is considered a directory and the links will be made under that directory. otherwise all the links will have the same destination.
Diffstat (limited to 'src/dotup.rs')
-rw-r--r--src/dotup.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dotup.rs b/src/dotup.rs
index 5f1287f..8de7920 100644
--- a/src/dotup.rs
+++ b/src/dotup.rs
@@ -132,7 +132,13 @@ impl Dotup {
132 pub fn link(&mut self, origin: impl AsRef<Path>, destination: impl AsRef<Path>) { 132 pub fn link(&mut self, origin: impl AsRef<Path>, destination: impl AsRef<Path>) {
133 let link_result: anyhow::Result<()> = try { 133 let link_result: anyhow::Result<()> = try {
134 let origin = self.prepare_relative_origin(origin.as_ref())?; 134 let origin = self.prepare_relative_origin(origin.as_ref())?;
135 let destination = self.prepare_relative_destination(destination.as_ref())?; 135 let destination_ends_with_slash = utils::path_ends_with_slash(destination.as_ref());
136 let mut destination = self.prepare_relative_destination(destination.as_ref())?;
137 if destination_ends_with_slash {
138 if let Some(filename) = origin.file_name() {
139 destination.push(filename);
140 }
141 }
136 self.depot.link_create(origin, destination)?; 142 self.depot.link_create(origin, destination)?;
137 }; 143 };
138 match link_result { 144 match link_result {