ui: add "is:" alias for "flags:" query

jmap
Manos Pitsidianakis 2019-11-11 22:48:39 +02:00
parent 6ce88667c0
commit 35e34d1c09
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 26 additions and 23 deletions

View File

@ -144,30 +144,33 @@ pub mod query_parser {
fn flags<'a>() -> impl Parser<'a, Query> { fn flags<'a>() -> impl Parser<'a, Query> {
move |input| { move |input| {
whitespace_wrap(match_literal_anycase("flags:")) whitespace_wrap(either(
.parse(input) match_literal_anycase("flags:"),
.and_then(|(rest, _)| { match_literal_anycase("is:"),
map(one_or_more(pred(any_char, |c| *c != ' ')), |chars| { ))
chars.into_iter().collect::<String>() .parse(input)
.and_then(|(rest, _)| {
map(one_or_more(pred(any_char, |c| *c != ' ')), |chars| {
chars.into_iter().collect::<String>()
})
.parse(rest)
})
.and_then(|(rest, flags_list)| {
if let Ok(r) = flags_list
.split(",")
.map(|t| {
either(quoted_string(), string())
.parse_complete(t)
.map(|(_, r)| r)
}) })
.parse(rest) .collect::<std::result::Result<Vec<String>, &str>>()
}) .map(|v| Flags(v))
.and_then(|(rest, flags_list)| { {
if let Ok(r) = flags_list Ok((rest, r))
.split(",") } else {
.map(|t| { Err(rest)
either(quoted_string(), string()) }
.parse_complete(t) })
.map(|(_, r)| r)
})
.collect::<std::result::Result<Vec<String>, &str>>()
.map(|v| Flags(v))
{
Ok((rest, r))
} else {
Err(rest)
}
})
} }
} }