mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Add filetype matcher
This commit is contained in:
parent
fb4f136c0d
commit
c6336cdf3c
2 changed files with 18 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue