database error
[notmuch-archives.git] / 00 / 4f45ea7a09843846463b1fe72d4fd1aca8e8c2
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 CD248429E37\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Nov 2014 17:50:23 -0700 (PDT)\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 I-gqKuylkl8w for <notmuch@notmuchmail.org>;\r
16         Sat,  1 Nov 2014 17:50:18 -0700 (PDT)\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 59976431FD9\r
19         for <notmuch@notmuchmail.org>; Sat,  1 Nov 2014 17:50:13 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 475765CD297\r
22         for <notmuch@notmuchmail.org>; Sun,  2 Nov 2014 01:50:12 +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 CyYUXw47bgNb for <notmuch@notmuchmail.org>;\r
27         Sun,  2 Nov 2014 01:50:07 +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 8D15E5CD28F\r
30         for <notmuch@notmuchmail.org>; Sun,  2 Nov 2014 01:50:06 +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 1XkjMq-00085G-IW; Sun, 02 Nov 2014 01:50:04 +0100\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: notmuch@notmuchmail.org\r
36 Subject: [PATCH 07/10] cli: search: Convert --output to keyword argument\r
37 Date: Sun,  2 Nov 2014 01:49:57 +0100\r
38 Message-Id: <1414889400-30977-8-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 2.1.1\r
40 In-Reply-To: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1414889400-30977-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: Sun, 02 Nov 2014 00:50:24 -0000\r
55 \r
56 Now, when address related outputs are in a separate command, it makes\r
57 no sense to combine multiple --output options in search command line.\r
58 Using switch statement to handle different outputs is more readable\r
59 than a series of if statements.\r
60 ---\r
61  doc/man1/notmuch-search.rst |  3 ---\r
62  notmuch-search.c            | 25 +++++++++++++------------\r
63  2 files changed, 13 insertions(+), 15 deletions(-)\r
64 \r
65 diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst\r
66 index e919811..e7b5ad4 100644\r
67 --- a/doc/man1/notmuch-search.rst\r
68 +++ b/doc/man1/notmuch-search.rst\r
69 @@ -78,9 +78,6 @@ Supported options for **search** include\r
70              by null characters (--format=text0), as a JSON array\r
71              (--format=json), or as an S-Expression list (--format=sexp).\r
72  \r
73 -       This option can be given multiple times to combine different\r
74 -       outputs.\r
75 -\r
76      ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)\r
77          This option can be used to present results in either\r
78          chronological order (**oldest-first**) or reverse chronological\r
79 diff --git a/notmuch-search.c b/notmuch-search.c\r
80 index 7a78ecd..4b9a372 100644\r
81 --- a/notmuch-search.c\r
82 +++ b/notmuch-search.c\r
83 @@ -572,7 +572,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
84      int opt_index, ret;\r
85  \r
86      notmuch_opt_desc_t options[] = {\r
87 -       { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',\r
88 +       { NOTMUCH_OPT_KEYWORD, &ctx->output, "output", 'o',\r
89           (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY },\r
90                                   { "threads", OUTPUT_THREADS },\r
91                                   { "messages", OUTPUT_MESSAGES },\r
92 @@ -586,28 +586,29 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
93         { 0, 0, 0, 0, 0 }\r
94      };\r
95  \r
96 +    ctx->output = OUTPUT_SUMMARY;\r
97      opt_index = parse_arguments (argc, argv, options, 1);\r
98      if (opt_index < 0)\r
99         return EXIT_FAILURE;\r
100  \r
101 -    if (! ctx->output)\r
102 -       ctx->output = OUTPUT_SUMMARY;\r
103 -\r
104      if (_notmuch_search_prepare (ctx, config,\r
105                                  argc - opt_index, argv + opt_index))\r
106         return EXIT_FAILURE;\r
107  \r
108 -    if (ctx->output == OUTPUT_SUMMARY ||\r
109 -       ctx->output == OUTPUT_THREADS)\r
110 +    switch (ctx->output) {\r
111 +    case OUTPUT_SUMMARY:\r
112 +    case OUTPUT_THREADS:\r
113         ret = do_search_threads (ctx);\r
114 -    else if (ctx->output == OUTPUT_MESSAGES ||\r
115 -            ctx->output == OUTPUT_FILES)\r
116 +       break;\r
117 +    case OUTPUT_MESSAGES:\r
118 +    case OUTPUT_FILES:\r
119         ret = do_search_messages (ctx);\r
120 -    else if (ctx->output == OUTPUT_TAGS)\r
121 +       break;\r
122 +    case OUTPUT_TAGS:\r
123         ret = do_search_tags (ctx);\r
124 -    else {\r
125 -       fprintf (stderr, "Error: the combination of outputs is not supported.\n");\r
126 -       ret = 1;\r
127 +       break;\r
128 +    default:\r
129 +       INTERNAL_ERROR ("Unexpected output");\r
130      }\r
131  \r
132      _notmuch_search_cleanup (ctx);\r
133 -- \r
134 2.1.1\r
135 \r