From 80bcbb07c92ebe737376ecfb867917c8324d77d8 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Tue, 15 Feb 2022 19:16:27 +0000 Subject: 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. --- src/dotup.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/dotup.rs') 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 { pub fn link(&mut self, origin: impl AsRef, destination: impl AsRef) { let link_result: anyhow::Result<()> = try { let origin = self.prepare_relative_origin(origin.as_ref())?; - let destination = self.prepare_relative_destination(destination.as_ref())?; + let destination_ends_with_slash = utils::path_ends_with_slash(destination.as_ref()); + let mut destination = self.prepare_relative_destination(destination.as_ref())?; + if destination_ends_with_slash { + if let Some(filename) = origin.file_name() { + destination.push(filename); + } + } self.depot.link_create(origin, destination)?; }; match link_result { -- cgit