From a98b50667bc6a11e4b8be464969adc14601e9e78 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Thu, 27 Apr 2023 17:59:33 -0500 Subject: feat: rewrite cli and add --all flag --- src/project/path.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/project') diff --git a/src/project/path.rs b/src/project/path.rs index fad746c..5954ff9 100644 --- a/src/project/path.rs +++ b/src/project/path.rs @@ -5,16 +5,23 @@ use tracing::debug; use super::{ProjectItem, ProjectParser}; #[derive(Debug, Clone)] -pub struct PathMatcher(pub String); +pub enum PathMatcher { + All(PathBuf), + Pattern(String), +} impl ProjectParser for PathMatcher { #[tracing::instrument] fn parse(&self, path_buf: PathBuf) -> Option { - if path_buf.join(&self.0).exists() { - Some(Box::new(PathProject::new(path_buf))) - } else { - debug!("Failed to match pattern in directory"); - None + match self { + PathMatcher::All(p) if &path_buf != p => Some(Box::new(PathProject::new(path_buf))), + PathMatcher::Pattern(p) if path_buf.join(p).exists() => { + Some(Box::new(PathProject::new(path_buf))) + } + _ => { + debug!("Failed to match pattern in directory"); + None + } } } } -- cgit v1.2.3-70-g09d2