diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | doc/aerc-search.1.scd | 7 | ||||
-rw-r--r-- | worker/imap/search.go | 8 | ||||
-rw-r--r-- | worker/lib/search.go | 8 | ||||
-rw-r--r-- | worker/maildir/search.go | 8 |
5 files changed, 28 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ffd198b2..36dc8f58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to aerc will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased](https://git.sr.ht/~rjarry/aerc/log/master) +- Search/filter by flags with the `-H` flag. ### Added diff --git a/doc/aerc-search.1.scd b/doc/aerc-search.1.scd index 9b375d55..68ec685a 100644 --- a/doc/aerc-search.1.scd +++ b/doc/aerc-search.1.scd @@ -6,7 +6,7 @@ aerc-search - search and filter patterns and options for *aerc*(1) # MAILDIR & IMAP -*search* [*-ruba*] [*-x* _<flag>_] [*-X* _<flag>_] [*-f* _<from>_] [*-t* _<to>_] [*-c* _<cc>_] [*-d* _<start[,end]>_] [_<terms>_...] +*search* [*-ruba*] [*-x* _<flag>_] [*-X* _<flag>_] [*-H* _Header: Value_] [*-f* _<from>_] [*-t* _<to>_] [*-c* _<cc>_] [*-d* _<start[,end]>_] [_<terms>_...] Searches the current folder for messages matching the given set of conditions. @@ -30,6 +30,11 @@ aerc-search - search and filter patterns and options for *aerc*(1) _Flagged_ Flagged messages + *-H*: Search in the headers of the messages, for a specific header + Syntax: _Header: Value_ + If the space between _:_ and the value is ommited, aerc will not + search for the Header. + *-b*: Search in the body of the messages *-a*: Search in the entire text of the messages diff --git a/worker/imap/search.go b/worker/imap/search.go index ba7b9174..77a18990 100644 --- a/worker/imap/search.go +++ b/worker/imap/search.go @@ -38,7 +38,13 @@ func parseSearch(args []string) (*imap.SearchCriteria, error) { criteria.WithoutFlags = append(criteria.WithoutFlags, f) } 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': diff --git a/worker/lib/search.go b/worker/lib/search.go index 0a124e3c..11fc1b11 100644 --- a/worker/lib/search.go +++ b/worker/lib/search.go @@ -44,7 +44,13 @@ func GetSearchCriteria(args []string) (*searchCriteria, error) { case 'X': 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': 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': |