diff options
Diffstat (limited to 'src/project/path.rs')
-rw-r--r-- | src/project/path.rs | 19 |
1 files changed, 13 insertions, 6 deletions
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<ProjectItem> { - 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 + } } } } |