mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
Add filetype matcher
This commit is contained in:
parent
fb4f136c0d
commit
c6336cdf3c
@ -203,6 +203,21 @@ impl TaggedFilterer {
|
|||||||
filter.matches(resolved.to_string_lossy())
|
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) => {
|
(Tag::FileEventKind(kind), Matcher::FileEventKind) => {
|
||||||
filter.matches(format!("{:?}", kind))
|
filter.matches(format!("{:?}", kind))
|
||||||
}
|
}
|
||||||
@ -405,6 +420,7 @@ impl Filter {
|
|||||||
pub enum Matcher {
|
pub enum Matcher {
|
||||||
Tag,
|
Tag,
|
||||||
Path,
|
Path,
|
||||||
|
FileType,
|
||||||
FileEventKind,
|
FileEventKind,
|
||||||
Source,
|
Source,
|
||||||
Process,
|
Process,
|
||||||
|
@ -22,6 +22,7 @@ impl FromStr for Filter {
|
|||||||
alt((
|
alt((
|
||||||
tag_no_case("tag"),
|
tag_no_case("tag"),
|
||||||
tag_no_case("path"),
|
tag_no_case("path"),
|
||||||
|
tag_no_case("type"),
|
||||||
tag_no_case("kind"),
|
tag_no_case("kind"),
|
||||||
tag_no_case("source"),
|
tag_no_case("source"),
|
||||||
tag_no_case("src"),
|
tag_no_case("src"),
|
||||||
@ -32,6 +33,7 @@ impl FromStr for Filter {
|
|||||||
|m: &str| match m.to_ascii_lowercase().as_str() {
|
|m: &str| match m.to_ascii_lowercase().as_str() {
|
||||||
"tag" => Ok(Matcher::Tag),
|
"tag" => Ok(Matcher::Tag),
|
||||||
"path" => Ok(Matcher::Path),
|
"path" => Ok(Matcher::Path),
|
||||||
|
"type" => Ok(Matcher::FileType),
|
||||||
"kind" => Ok(Matcher::FileEventKind),
|
"kind" => Ok(Matcher::FileEventKind),
|
||||||
"source" => Ok(Matcher::Source),
|
"source" => Ok(Matcher::Source),
|
||||||
"src" => Ok(Matcher::Source),
|
"src" => Ok(Matcher::Source),
|
||||||
|
Loading…
Reference in New Issue
Block a user