aboutsummaryrefslogtreecommitdiff
path: root/src/dotup.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2022-02-15 18:27:30 +0000
committerdiogo464 <[email protected]>2022-02-15 18:27:30 +0000
commit00e94787e0e473f733b15da24ebe64ed0f595a9e (patch)
treecbcf21bdcaf67a54f88aa4b6be7f7d708fa00725 /src/dotup.rs
parent4b524a27edb8cd51f04bfc9bd79dfd17ab31003b (diff)
improved status command
allow specifying the paths that the status should be printed for instead of displaying everything
Diffstat (limited to 'src/dotup.rs')
-rw-r--r--src/dotup.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotup.rs b/src/dotup.rs
index a7cccbe..296b182 100644
--- a/src/dotup.rs
+++ b/src/dotup.rs
@@ -287,11 +287,18 @@ impl Dotup {
287 Ok(()) 287 Ok(())
288 } 288 }
289 289
290 pub fn status(&self) { 290 pub fn status(&self, paths: impl Iterator<Item = impl AsRef<Path>>) {
291 let status_result: anyhow::Result<()> = try { 291 let status_result: anyhow::Result<()> = try {
292 let canonical_dir = utils::current_working_directory(); 292 // canonicalize and remove paths whose parent we already have
293 let item = self.status_path_to_item(&canonical_dir)?; 293 let paths = paths.map(utils::weakly_canonical).collect::<HashSet<_>>();
294 self.status_print_item(item, 0)?; 294 let paths = paths
295 .iter()
296 .filter(|p| !paths.iter().any(|x| p.starts_with(x) && p != &x));
297
298 for path in paths {
299 let item = self.status_path_to_item(path)?;
300 self.status_print_item(item, 0)?;
301 }
295 }; 302 };
296 if let Err(e) = status_result { 303 if let Err(e) = status_result {
297 println!("error while displaying status : {e}"); 304 println!("error while displaying status : {e}");