From 00e94787e0e473f733b15da24ebe64ed0f595a9e Mon Sep 17 00:00:00 2001 From: diogo464 Date: Tue, 15 Feb 2022 18:27:30 +0000 Subject: improved status command allow specifying the paths that the status should be printed for instead of displaying everything --- src/dotup.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/dotup.rs') 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 { Ok(()) } - pub fn status(&self) { + pub fn status(&self, paths: impl Iterator>) { let status_result: anyhow::Result<()> = try { - let canonical_dir = utils::current_working_directory(); - let item = self.status_path_to_item(&canonical_dir)?; - self.status_print_item(item, 0)?; + // canonicalize and remove paths whose parent we already have + let paths = paths.map(utils::weakly_canonical).collect::>(); + let paths = paths + .iter() + .filter(|p| !paths.iter().any(|x| p.starts_with(x) && p != &x)); + + for path in paths { + let item = self.status_path_to_item(path)?; + self.status_print_item(item, 0)?; + } }; if let Err(e) = status_result { println!("error while displaying status : {e}"); -- cgit