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 13557431FAF
\r
6 for <notmuch@notmuchmail.org>; Mon, 3 Nov 2014 15:51:19 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 Ewmt8mnB6ANk for <notmuch@notmuchmail.org>;
\r
16 Mon, 3 Nov 2014 15:51:13 -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 93155429E34
\r
19 for <notmuch@notmuchmail.org>; Mon, 3 Nov 2014 15:50:52 -0800 (PST)
\r
20 Received: from localhost (unknown [192.168.200.7])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 147A55CD008
\r
22 for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 00:50:52 +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 USTgdAnh_uU9 for <notmuch@notmuchmail.org>;
\r
27 Tue, 4 Nov 2014 00:50:45 +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 E2D2A5CD00B
\r
30 for <notmuch@notmuchmail.org>; Tue, 4 Nov 2014 00:50:40 +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 1XlROM-0005Wn-6Y; Tue, 04 Nov 2014 00:50:34 +0100
\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH v2 07/10] cli: search: Convert --output to keyword argument
\r
37 Date: Tue, 4 Nov 2014 00:50:19 +0100
\r
38 Message-Id: <1415058622-21162-8-git-send-email-sojkam1@fel.cvut.cz>
\r
39 X-Mailer: git-send-email 2.1.1
\r
40 In-Reply-To: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>
\r
41 References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\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: Mon, 03 Nov 2014 23:51:19 -0000
\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
61 doc/man1/notmuch-search.rst | 3 ---
\r
62 notmuch-search.c | 25 +++++++++++++------------
\r
63 2 files changed, 13 insertions(+), 15 deletions(-)
\r
65 diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst
\r
66 index 65df288..0cc2911 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
73 - This option can be given multiple times to combine different
\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 cbd84f5..402e860 100644
\r
81 --- a/notmuch-search.c
\r
82 +++ b/notmuch-search.c
\r
83 @@ -593,7 +593,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\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 @@ -607,13 +607,11 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
96 + ctx->output = OUTPUT_SUMMARY;
\r
97 opt_index = parse_arguments (argc, argv, options, 1);
\r
99 return EXIT_FAILURE;
\r
101 - if (! ctx->output)
\r
102 - ctx->output = OUTPUT_SUMMARY;
\r
104 if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES &&
\r
106 fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n");
\r
107 @@ -624,17 +622,20 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])
\r
108 argc - opt_index, argv + opt_index))
\r
109 return EXIT_FAILURE;
\r
111 - if (ctx->output == OUTPUT_SUMMARY ||
\r
112 - ctx->output == OUTPUT_THREADS)
\r
113 + switch (ctx->output) {
\r
114 + case OUTPUT_SUMMARY:
\r
115 + case OUTPUT_THREADS:
\r
116 ret = do_search_threads (ctx);
\r
117 - else if (ctx->output == OUTPUT_MESSAGES ||
\r
118 - ctx->output == OUTPUT_FILES)
\r
120 + case OUTPUT_MESSAGES:
\r
121 + case OUTPUT_FILES:
\r
122 ret = do_search_messages (ctx);
\r
123 - else if (ctx->output == OUTPUT_TAGS)
\r
125 + case OUTPUT_TAGS:
\r
126 ret = do_search_tags (ctx);
\r
128 - fprintf (stderr, "Error: the combination of outputs is not supported.\n");
\r
132 + INTERNAL_ERROR ("Unexpected output");
\r
135 _notmuch_search_cleanup (ctx);
\r