Add filetype matcher

This commit is contained in:
Félix Saparelli 2021-10-13 04:06:55 +13:00
parent fb4f136c0d
commit c6336cdf3c
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
2 changed files with 18 additions and 0 deletions

View File

@ -203,6 +203,21 @@ impl TaggedFilterer {
filter.matches(resolved.to_string_lossy())
}
}
(
Tag::Path {
file_type: Some(ft),
..
},
Matcher::FileType,
) => filter.matches(if ft.is_dir() {
"dir"
} else if ft.is_file() {
"file"
} else if ft.is_symlink() {
"symlink"
} else {
"special"
}),
(Tag::FileEventKind(kind), Matcher::FileEventKind) => {
filter.matches(format!("{:?}", kind))
}
@ -405,6 +420,7 @@ impl Filter {
pub enum Matcher {
Tag,
Path,
FileType,
FileEventKind,
Source,
Process,

View File

@ -22,6 +22,7 @@ impl FromStr for Filter {
alt((
tag_no_case("tag"),
tag_no_case("path"),
tag_no_case("type"),
tag_no_case("kind"),
tag_no_case("source"),
tag_no_case("src"),
@ -32,6 +33,7 @@ impl FromStr for Filter {
|m: &str| match m.to_ascii_lowercase().as_str() {
"tag" => Ok(Matcher::Tag),
"path" => Ok(Matcher::Path),
"type" => Ok(Matcher::FileType),
"kind" => Ok(Matcher::FileEventKind),
"source" => Ok(Matcher::Source),
"src" => Ok(Matcher::Source),