Change process completion auto op to glob

This commit is contained in:
Félix Saparelli 2021-12-21 17:49:24 +13:00
parent 5856f976db
commit e7de00edfe
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
2 changed files with 8 additions and 3 deletions

View File

@ -70,7 +70,7 @@ pub mod swaplock;
/// | [Source](Matcher::Source) | `:=` (in set) |
/// | [Process](Matcher::Process) | `:=` (in set) |
/// | [Signal](Matcher::Signal) | `:=` (in set) |
/// | [ProcessCompletion](Matcher::ProcessCompletion) | `:=` (in set) |
/// | [ProcessCompletion](Matcher::ProcessCompletion) | `*=` (glob) |
///
/// [Matchers][Matcher] correspond to Tags, but are not one-to-one: the `path` matcher operates on
/// the `path` part of the `Path` tag, and the `type` matcher operates on the `file_type`, for

View File

@ -94,14 +94,19 @@ impl FromStr for Filter {
on: m,
op: match o {
Op::Auto => match m {
Matcher::Path | Matcher::FileEventKind => Op::Glob,
Matcher::Path
| Matcher::FileEventKind
| Matcher::ProcessCompletion => Op::Glob,
_ => Op::InSet,
},
o => o,
},
pat: match (o, m) {
// TODO: carry regex/glob errors through
(Op::Auto, Matcher::Path | Matcher::FileEventKind)
(
Op::Auto,
Matcher::Path | Matcher::FileEventKind | Matcher::ProcessCompletion,
)
| (Op::Glob | Op::NotGlob, _) => Pattern::Glob(p.to_string()),
(Op::Auto | Op::InSet | Op::NotInSet, _) => {
Pattern::Set(p.split(',').map(|s| s.trim().to_string()).collect())