diff options
author | Julian Marcos <jmjl@tilde.green> | 2023-04-17 06:22:11 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:50:37 +0200 |
commit | 96d5b4e149dccfdb75d41785e6525b647925f8ce (patch) | |
tree | 3ca3f3761c3abdc12e1159773e5e6bca80ba1e54 /worker/maildir/search.go | |
parent | d8c2d63ee9b37e78d0e06ec71b2227b83ee52aa5 (diff) | |
download | aerc-96d5b4e149dccfdb75d41785e6525b647925f8ce.tar.gz |
search: handle headers in search/filter query
Handle headers in the search and filter commands, for searching and
filtering based on the Headers specified by the -H parameter, the syntax
for the -H parameter should be `Header: Key`.
Signed-off-by: Julian Marcos <jmjl@tilde.green>
Acked-by: Robin Jarry<robin@jarry.cc>
Diffstat (limited to 'worker/maildir/search.go')
-rw-r--r-- | worker/maildir/search.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/worker/maildir/search.go b/worker/maildir/search.go index c667d48f..49cb1c6e 100644 --- a/worker/maildir/search.go +++ b/worker/maildir/search.go @@ -50,7 +50,13 @@ func parseSearch(args []string) (*searchCriteria, error) { case 'X': criteria.WithoutFlags = append(criteria.WithoutFlags, getParsedFlag(opt.Value)) case 'H': - // TODO + if strings.Contains(opt.Value, ": ") { + HeaderValue := strings.SplitN(opt.Value, ": ", 2) + criteria.Header.Add(HeaderValue[0], HeaderValue[1]) + } else { + log.Errorf("Header is not given properly, must be given in format `Header: Value`") + continue + } case 'f': criteria.Header.Add("From", opt.Value) case 't': |