Re: [RFC PATCH 5/5] cli: add support for deduplicating based on case insensitive...
[notmuch-archives.git] / 4d / b729db509186b870552153ae541a91e8d78dc0
1 Return-Path: <sojkam1@fel.cvut.cz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 9A7F9429E38\r
6         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 16:26:52 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id Rsqeu-H1y4nt for <notmuch@notmuchmail.org>;\r
16         Tue,  4 Nov 2014 16:26:44 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 785DC431FC3\r
19         for <notmuch@notmuchmail.org>; Tue,  4 Nov 2014 16:26:22 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id D47BD5CD1AA\r
22         for <notmuch@notmuchmail.org>; Wed,  5 Nov 2014 01:26:21 +0100 (CET)\r
23 X-Virus-Scanned: IMAP STYX AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
26         port 10044) with ESMTP id ekCy3NQNhquW for <notmuch@notmuchmail.org>;\r
27         Wed,  5 Nov 2014 01:26:17 +0100 (CET)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id 42D815CD1AD\r
30         for <notmuch@notmuchmail.org>; Wed,  5 Nov 2014 01:26:14 +0100 (CET)\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
32         (envelope-from <sojkam1@fel.cvut.cz>)\r
33         id 1XloQI-0005D2-TT; Wed, 05 Nov 2014 01:26:06 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH v3 06/10] cli: Introduce "notmuch address" command\r
37 Date: Wed,  5 Nov 2014 01:25:55 +0100\r
38 Message-Id: <1415147159-19946-7-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 2.1.1\r
40 In-Reply-To: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1415147159-19946-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Wed, 05 Nov 2014 00:26:52 -0000\r
55 \r
56 This moves address-related functionality from search command to the\r
57 new address command. The implementation shares almost all code and\r
58 some command line options.\r
59 \r
60 Options --offset and --limit were intentionally not included in the\r
61 address command, because they refer to messages numbers, which users\r
62 do not see in the output. This could confuse users because, for\r
63 example, they could see more addresses in the output that what was\r
64 specified with --limit. This functionality can be correctly\r
65 reimplemented for address subcommand later.\r
66 \r
67 Also useless values of --exclude flag were not included in the address\r
68 command.\r
69 \r
70 This was inspired by a patch from Jani Nikula.\r
71 ---\r
72  completion/notmuch-completion.bash | 42 ++++++++++++++++-\r
73  completion/notmuch-completion.zsh  | 10 +++-\r
74  doc/man1/notmuch-address.rst       | 89 ++++++++++++++++++++++++++++++++++++\r
75  doc/man1/notmuch-search.rst        | 20 +-------\r
76  doc/man1/notmuch.rst               |  7 +--\r
77  notmuch-client.h                   |  3 ++\r
78  notmuch-search.c                   | 93 +++++++++++++++++++++++++++-----------\r
79  notmuch.c                          |  2 +\r
80  8 files changed, 216 insertions(+), 50 deletions(-)\r
81  create mode 100644 doc/man1/notmuch-address.rst\r
82 \r
83 diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
84 index cfbd389..94ea2d5 100644\r
85 --- a/completion/notmuch-completion.bash\r
86 +++ b/completion/notmuch-completion.bash\r
87 @@ -294,7 +294,7 @@ _notmuch_search()\r
88             return\r
89             ;;\r
90         --output)\r
91 -           COMPREPLY=( $( compgen -W "summary threads messages files tags sender recipients" -- "${cur}" ) )\r
92 +           COMPREPLY=( $( compgen -W "summary threads messages files tags" -- "${cur}" ) )\r
93             return\r
94             ;;\r
95         --sort)\r
96 @@ -320,6 +320,44 @@ _notmuch_search()\r
97      esac\r
98  }\r
99  \r
100 +_notmuch_address()\r
101 +{\r
102 +    local cur prev words cword split\r
103 +    _init_completion -s || return\r
104 +\r
105 +    $split &&\r
106 +    case "${prev}" in\r
107 +       --format)\r
108 +           COMPREPLY=( $( compgen -W "json sexp text text0" -- "${cur}" ) )\r
109 +           return\r
110 +           ;;\r
111 +       --output)\r
112 +           COMPREPLY=( $( compgen -W "sender recipients" -- "${cur}" ) )\r
113 +           return\r
114 +           ;;\r
115 +       --sort)\r
116 +           COMPREPLY=( $( compgen -W "newest-first oldest-first" -- "${cur}" ) )\r
117 +           return\r
118 +           ;;\r
119 +       --exclude)\r
120 +           COMPREPLY=( $( compgen -W "true false flag all" -- "${cur}" ) )\r
121 +           return\r
122 +           ;;\r
123 +    esac\r
124 +\r
125 +    ! $split &&\r
126 +    case "${cur}" in\r
127 +       -*)\r
128 +           local options="--format= --output= --sort= --exclude="\r
129 +           compopt -o nospace\r
130 +           COMPREPLY=( $(compgen -W "$options" -- ${cur}) )\r
131 +           ;;\r
132 +       *)\r
133 +           _notmuch_search_terms\r
134 +           ;;\r
135 +    esac\r
136 +}\r
137 +\r
138  _notmuch_show()\r
139  {\r
140      local cur prev words cword split\r
141 @@ -393,7 +431,7 @@ _notmuch_tag()\r
142  \r
143  _notmuch()\r
144  {\r
145 -    local _notmuch_commands="compact config count dump help insert new reply restore search setup show tag"\r
146 +    local _notmuch_commands="compact config count dump help insert new reply restore search address setup show tag"\r
147      local arg cur prev words cword split\r
148  \r
149      # require bash-completion with _init_completion\r
150 diff --git a/completion/notmuch-completion.zsh b/completion/notmuch-completion.zsh\r
151 index 3e52a00..c606b75 100644\r
152 --- a/completion/notmuch-completion.zsh\r
153 +++ b/completion/notmuch-completion.zsh\r
154 @@ -10,6 +10,7 @@ _notmuch_commands()\r
155      'setup:interactively set up notmuch for first use'\r
156      'new:find and import any new message to the database'\r
157      'search:search for messages matching the search terms, display matching threads as results'\r
158 +    'address:get addresses from messages matching the given search terms'\r
159      'reply:constructs a reply template for a set of messages'\r
160      'show:show all messages matching the search terms'\r
161      'tag:add or remove tags for all messages matching the search terms'\r
162 @@ -53,7 +54,14 @@ _notmuch_search()\r
163      '--max-threads=[display only the first x threads from the search results]:number of threads to show: ' \\r
164      '--first=[omit the first x threads from the search results]:number of threads to omit: ' \\r
165      '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \\r
166 -    '--output=[select what to output]:output:((summary threads messages files tags sender recipients))'\r
167 +    '--output=[select what to output]:output:((summary threads messages files tags))'\r
168 +}\r
169 +\r
170 +_notmuch_address()\r
171 +{\r
172 +  _arguments -s : \\r
173 +    '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' \\r
174 +    '--output=[select what to output]:output:((sender recipients))'\r
175  }\r
176  \r
177  _notmuch()\r
178 diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst\r
179 new file mode 100644\r
180 index 0000000..d349237\r
181 --- /dev/null\r
182 +++ b/doc/man1/notmuch-address.rst\r
183 @@ -0,0 +1,89 @@\r
184 +===============\r
185 +notmuch-address\r
186 +===============\r
187 +\r
188 +SYNOPSIS\r
189 +========\r
190 +\r
191 +**notmuch** **address** [*option* ...] <*search-term*> ...\r
192 +\r
193 +DESCRIPTION\r
194 +===========\r
195 +\r
196 +Search for messages matching the given search terms, and display the\r
197 +addresses from them.\r
198 +\r
199 +See **notmuch-search-terms(7)** for details of the supported syntax for\r
200 +<search-terms>.\r
201 +\r
202 +Supported options for **address** include\r
203 +\r
204 +    ``--format=``\ (**json**\ \|\ **sexp**\ \|\ **text**\ \|\ **text0**)\r
205 +        Presents the results in either JSON, S-Expressions, newline\r
206 +        character separated plain-text (default), or null character\r
207 +        separated plain-text (compatible with **xargs(1)** -0 option\r
208 +        where available).\r
209 +\r
210 +    ``--format-version=N``\r
211 +        Use the specified structured output format version. This is\r
212 +        intended for programs that invoke **notmuch(1)** internally. If\r
213 +        omitted, the latest supported version will be used.\r
214 +\r
215 +    ``--output=(sender|recipients)``\r
216 +\r
217 +        Controls which information appears in the output. This option\r
218 +       can be given multiple times to combine different outputs.\r
219 +       Omitting this option is equivalent to\r
220 +       --output=sender --output=recipients.\r
221 +\r
222 +       **sender**\r
223 +            Output all addresses from the *From* header.\r
224 +\r
225 +           Note: Searching for **sender** should be much faster than\r
226 +           searching for **recipients**, because sender addresses are\r
227 +           cached directly in the database whereas other addresses\r
228 +           need to be fetched from message files.\r
229 +\r
230 +       **recipients**\r
231 +            Output all addresses from the *To*, *Cc* and *Bcc*\r
232 +            headers.\r
233 +\r
234 +    ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
235 +        This option can be used to present results in either\r
236 +        chronological order (**oldest-first**) or reverse chronological\r
237 +        order (**newest-first**).\r
238 +\r
239 +        By default, results will be displayed in reverse chronological\r
240 +        order, (that is, the newest results will be displayed first).\r
241 +\r
242 +    ``--exclude=(true|false)``\r
243 +        A message is called "excluded" if it matches at least one tag in\r
244 +        search.tag\_exclude that does not appear explicitly in the\r
245 +        search terms. This option specifies whether to omit excluded\r
246 +        messages in the search process.\r
247 +\r
248 +        The default value, **true**, prevents excluded messages from\r
249 +        matching the search terms.\r
250 +\r
251 +        **false** allows excluded messages to match search terms and\r
252 +        appear in displayed results.\r
253 +\r
254 +EXIT STATUS\r
255 +===========\r
256 +\r
257 +This command supports the following special exit status codes\r
258 +\r
259 +``20``\r
260 +    The requested format version is too old.\r
261 +\r
262 +``21``\r
263 +    The requested format version is too new.\r
264 +\r
265 +SEE ALSO\r
266 +========\r
267 +\r
268 +**notmuch(1)**, **notmuch-config(1)**, **notmuch-count(1)**,\r
269 +**notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,\r
270 +**notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,\r
271 +**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**,\r
272 +***notmuch-search(1)**\r
273 diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst\r
274 index 8110086..65df288 100644\r
275 --- a/doc/man1/notmuch-search.rst\r
276 +++ b/doc/man1/notmuch-search.rst\r
277 @@ -78,25 +78,8 @@ Supported options for **search** include\r
278              by null characters (--format=text0), as a JSON array\r
279              (--format=json), or as an S-Expression list (--format=sexp).\r
280  \r
281 -       **sender**\r
282 -            Output all addresses from the *From* header that appear on\r
283 -            any message matching the search terms, either one per line\r
284 -            (--format=text), separated by null characters\r
285 -            (--format=text0), as a JSON array (--format=json), or as\r
286 -            an S-Expression list (--format=sexp).\r
287 -\r
288 -           Note: Searching for **sender** should be much faster than\r
289 -           searching for **recipients**, because sender addresses are\r
290 -           cached directly in the database whereas other addresses\r
291 -           need to be fetched from message files.\r
292 -\r
293 -       **recipients**\r
294 -            Like **sender** but for addresses from *To*, *Cc* and\r
295 -           *Bcc* headers.\r
296 -\r
297         This option can be given multiple times to combine different\r
298 -       outputs. Currently, this is only supported for **sender** and\r
299 -       **recipients** outputs.\r
300 +       outputs.\r
301  \r
302      ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
303          This option can be used to present results in either\r
304 @@ -173,3 +156,4 @@ SEE ALSO\r
305  **notmuch-dump(1)**, **notmuch-hooks(5)**, **notmuch-insert(1)**,\r
306  **notmuch-new(1)**, **notmuch-reply(1)**, **notmuch-restore(1)**,\r
307  **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**\r
308 +***notmuch-address(1)**\r
309 diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst\r
310 index 9710294..98590a4 100644\r
311 --- a/doc/man1/notmuch.rst\r
312 +++ b/doc/man1/notmuch.rst\r
313 @@ -88,8 +88,8 @@ Several of the notmuch commands accept search terms with a common\r
314  syntax. See **notmuch-search-terms**\ (7) for more details on the\r
315  supported syntax.\r
316  \r
317 -The **search**, **show** and **count** commands are used to query the\r
318 -email database.\r
319 +The **search**, **show**, **address** and **count** commands are used\r
320 +to query the email database.\r
321  \r
322  The **reply** command is useful for preparing a template for an email\r
323  reply.\r
324 @@ -128,7 +128,8 @@ SEE ALSO\r
325  **notmuch-config(1)**, **notmuch-count(1)**, **notmuch-dump(1)**,\r
326  **notmuch-hooks(5)**, **notmuch-insert(1)**, **notmuch-new(1)**,\r
327  **notmuch-reply(1)**, **notmuch-restore(1)**, **notmuch-search(1)**,\r
328 -**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**\r
329 +**notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**,\r
330 +***notmuch-address(1)**\r
331  \r
332  The notmuch website: **http://notmuchmail.org**\r
333  \r
334 diff --git a/notmuch-client.h b/notmuch-client.h\r
335 index e1efbe0..5e0d475 100644\r
336 --- a/notmuch-client.h\r
337 +++ b/notmuch-client.h\r
338 @@ -199,6 +199,9 @@ int\r
339  notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]);\r
340  \r
341  int\r
342 +notmuch_address_command (notmuch_config_t *config, int argc, char *argv[]);\r
343 +\r
344 +int\r
345  notmuch_setup_command (notmuch_config_t *config, int argc, char *argv[]);\r
346  \r
347  int\r
348 diff --git a/notmuch-search.c b/notmuch-search.c\r
349 index f115359..69938d6 100644\r
350 --- a/notmuch-search.c\r
351 +++ b/notmuch-search.c\r
352 @@ -23,17 +23,18 @@\r
353  #include "string-util.h"\r
354  \r
355  typedef enum {\r
356 +    /* Search command */\r
357      OUTPUT_SUMMARY     = 1 << 0,\r
358      OUTPUT_THREADS     = 1 << 1,\r
359      OUTPUT_MESSAGES    = 1 << 2,\r
360      OUTPUT_FILES       = 1 << 3,\r
361      OUTPUT_TAGS                = 1 << 4,\r
362 +\r
363 +    /* Address command */\r
364      OUTPUT_SENDER      = 1 << 5,\r
365      OUTPUT_RECIPIENTS  = 1 << 6,\r
366  } output_t;\r
367  \r
368 -#define OUTPUT_ADDRESS_FLAGS (OUTPUT_SENDER | OUTPUT_RECIPIENTS)\r
369 -\r
370  typedef enum {\r
371      NOTMUCH_FORMAT_JSON,\r
372      NOTMUCH_FORMAT_TEXT,\r
373 @@ -554,39 +555,42 @@ _notmuch_search_cleanup (search_context_t *ctx)\r
374      talloc_free (ctx->format);\r
375  }\r
376  \r
377 +static search_context_t search_context = {\r
378 +    .format_sel = NOTMUCH_FORMAT_TEXT,\r
379 +    .exclude = NOTMUCH_EXCLUDE_TRUE,\r
380 +    .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
381 +    .output = 0,\r
382 +    .offset = 0,\r
383 +    .limit = -1, /* unlimited */\r
384 +    .dupe = -1,\r
385 +};\r
386 +\r
387 +static const notmuch_opt_desc_t common_options[] = {\r
388 +    { NOTMUCH_OPT_KEYWORD, &search_context.sort, "sort", 's',\r
389 +      (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
390 +                             { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
391 +                             { 0, 0 } } },\r
392 +    { NOTMUCH_OPT_KEYWORD, &search_context.format_sel, "format", 'f',\r
393 +      (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
394 +                             { "sexp", NOTMUCH_FORMAT_SEXP },\r
395 +                             { "text", NOTMUCH_FORMAT_TEXT },\r
396 +                             { "text0", NOTMUCH_FORMAT_TEXT0 },\r
397 +                             { 0, 0 } } },\r
398 +    { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },\r
399 +    { 0, 0, 0, 0, 0 }\r
400 +};\r
401 +\r
402  int\r
403  notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
404  {\r
405 -    search_context_t search_context = {\r
406 -       .format_sel = NOTMUCH_FORMAT_TEXT,\r
407 -       .exclude = NOTMUCH_EXCLUDE_TRUE,\r
408 -       .sort = NOTMUCH_SORT_NEWEST_FIRST,\r
409 -       .output = 0,\r
410 -       .offset = 0,\r
411 -       .limit = -1, /* unlimited */\r
412 -       .dupe = -1,\r
413 -    };\r
414      search_context_t *ctx = &search_context;\r
415      int opt_index, ret;\r
416  \r
417      notmuch_opt_desc_t options[] = {\r
418 -       { NOTMUCH_OPT_KEYWORD, &ctx->sort, "sort", 's',\r
419 -         (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },\r
420 -                                 { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },\r
421 -                                 { 0, 0 } } },\r
422 -       { NOTMUCH_OPT_KEYWORD, &ctx->format_sel, "format", 'f',\r
423 -         (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
424 -                                 { "sexp", NOTMUCH_FORMAT_SEXP },\r
425 -                                 { "text", NOTMUCH_FORMAT_TEXT },\r
426 -                                 { "text0", NOTMUCH_FORMAT_TEXT0 },\r
427 -                                 { 0, 0 } } },\r
428 -       { NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },\r
429         { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
430           (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
431                                   { "threads", OUTPUT_THREADS },\r
432                                   { "messages", OUTPUT_MESSAGES },\r
433 -                                 { "sender", OUTPUT_SENDER },\r
434 -                                 { "recipients", OUTPUT_RECIPIENTS },\r
435                                   { "files", OUTPUT_FILES },\r
436                                   { "tags", OUTPUT_TAGS },\r
437                                   { 0, 0 } } },\r
438 @@ -599,6 +603,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
439         { NOTMUCH_OPT_INT, &ctx->offset, "offset", 'O', 0 },\r
440         { NOTMUCH_OPT_INT, &ctx->limit, "limit", 'L', 0  },\r
441         { NOTMUCH_OPT_INT, &ctx->dupe, "duplicate", 'D', 0  },\r
442 +       { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },\r
443         { 0, 0, 0, 0, 0 }\r
444      };\r
445  \r
446 @@ -623,8 +628,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
447         ctx->output == OUTPUT_THREADS)\r
448         ret = do_search_threads (ctx);\r
449      else if (ctx->output == OUTPUT_MESSAGES ||\r
450 -            ctx->output == OUTPUT_FILES ||\r
451 -            (ctx->output & OUTPUT_ADDRESS_FLAGS && !(ctx->output & ~OUTPUT_ADDRESS_FLAGS)))\r
452 +            ctx->output == OUTPUT_FILES)\r
453         ret = do_search_messages (ctx);\r
454      else if (ctx->output == OUTPUT_TAGS)\r
455         ret = do_search_tags (ctx);\r
456 @@ -637,3 +641,40 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
457  \r
458      return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
459  }\r
460 +\r
461 +int\r
462 +notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])\r
463 +{\r
464 +    search_context_t *ctx = &search_context;\r
465 +    int opt_index, ret;\r
466 +\r
467 +    notmuch_opt_desc_t options[] = {\r
468 +       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
469 +         (notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },\r
470 +                                 { "recipients", OUTPUT_RECIPIENTS },\r
471 +                                 { 0, 0 } } },\r
472 +       { NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',\r
473 +         (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },\r
474 +                                 { "false", NOTMUCH_EXCLUDE_FALSE },\r
475 +                                 { 0, 0 } } },\r
476 +       { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },\r
477 +       { 0, 0, 0, 0, 0 }\r
478 +    };\r
479 +\r
480 +    opt_index = parse_arguments (argc, argv, options, 1);\r
481 +    if (opt_index < 0)\r
482 +       return EXIT_FAILURE;\r
483 +\r
484 +    if (! ctx->output)\r
485 +       ctx->output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;\r
486 +\r
487 +    if (_notmuch_search_prepare (ctx, config,\r
488 +                                argc - opt_index, argv + opt_index))\r
489 +       return EXIT_FAILURE;\r
490 +\r
491 +    ret = do_search_messages (ctx);\r
492 +\r
493 +    _notmuch_search_cleanup (ctx);\r
494 +\r
495 +    return ret ? EXIT_FAILURE : EXIT_SUCCESS;\r
496 +}\r
497 diff --git a/notmuch.c b/notmuch.c\r
498 index dcda039..0fac099 100644\r
499 --- a/notmuch.c\r
500 +++ b/notmuch.c\r
501 @@ -54,6 +54,8 @@ static command_t commands[] = {\r
502        "Add a new message into the maildir and notmuch database." },\r
503      { "search", notmuch_search_command, FALSE,\r
504        "Search for messages matching the given search terms." },\r
505 +    { "address", notmuch_address_command, FALSE,\r
506 +      "Get addresses from messages matching the given search terms." },\r
507      { "show", notmuch_show_command, FALSE,\r
508        "Show all messages matching the search terms." },\r
509      { "count", notmuch_count_command, FALSE,\r
510 -- \r
511 2.1.1\r
512 \r