1 Return-Path: <jani@nikula.org>
\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 CE14F429E3F
\r
6 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 13:16:09 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id J69qnOsi2TC7 for <notmuch@notmuchmail.org>;
\r
17 Sun, 13 Nov 2011 13:16:07 -0800 (PST)
\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com
\r
19 [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id E111B429E3D
\r
22 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 13:15:54 -0800 (PST)
\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so6289712bka.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 13:15:54 -0800 (PST)
\r
25 Received: by 10.204.156.208 with SMTP id y16mr16708507bkw.72.1321218954421;
\r
26 Sun, 13 Nov 2011 13:15:54 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id j9sm27632887bkd.2.2011.11.13.13.15.52
\r
30 (version=SSLv3 cipher=OTHER); Sun, 13 Nov 2011 13:15:53 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH v6 4/6] cli: add support for --output parameter in notmuch
\r
35 Date: Sun, 13 Nov 2011 23:15:33 +0200
\r
37 <b92c22c84bd5ae66e6bfb400cb20c87e1ac09c45.1321217854.git.jani@nikula.org>
\r
38 X-Mailer: git-send-email 1.7.5.4
\r
39 In-Reply-To: <cover.1321217854.git.jani@nikula.org>
\r
40 References: <cover.1321217854.git.jani@nikula.org>
\r
41 In-Reply-To: <cover.1321217854.git.jani@nikula.org>
\r
42 References: <cover.1321217854.git.jani@nikula.org>
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Sun, 13 Nov 2011 21:16:10 -0000
\r
57 Add support for --output=messages (which remains the default) and
\r
58 --output=threads to notmuch count.
\r
60 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
63 notmuch-count.c | 18 ++++++++++++++++--
\r
64 notmuch.1 | 29 +++++++++++++++++++++++++----
\r
65 notmuch.c | 20 ++++++++++++++++----
\r
66 4 files changed, 62 insertions(+), 10 deletions(-)
\r
68 diff --git a/NEWS b/NEWS
\r
69 index abc749a..78434d9 100644
\r
72 @@ -28,6 +28,11 @@ Add "notmuch search" --first and --maxitems options
\r
73 The search command now takes options --first=[-]N and --maxitems=N to limit
\r
74 the number of results shown.
\r
76 +Add "notmuch count --output" option
\r
78 + The count command is now capable of counting threads in addition to
\r
79 + messages. This is selected using the new --output=(threads|messages) option.
\r
81 Notmuch 0.9 (2011-10-01)
\r
82 ========================
\r
84 diff --git a/notmuch-count.c b/notmuch-count.c
\r
85 index a35be40..20ce334 100644
\r
86 --- a/notmuch-count.c
\r
87 +++ b/notmuch-count.c
\r
88 @@ -29,6 +29,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
89 notmuch_query_t *query;
\r
92 + notmuch_bool_t output_messages = TRUE;
\r
94 argc--; argv++; /* skip subcommand argument */
\r
96 @@ -37,7 +38,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
101 + if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {
\r
102 + const char *opt = argv[i] + sizeof ("--output=") - 1;
\r
103 + if (strcmp (opt, "threads") == 0) {
\r
104 + output_messages = FALSE;
\r
105 + } else if (strcmp (opt, "messages") == 0) {
\r
106 + output_messages = TRUE;
\r
108 + fprintf (stderr, "Invalid value for --output: %s\n", opt);
\r
112 fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
\r
115 @@ -71,7 +82,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
119 - printf ("%u\n", notmuch_query_count_messages(query));
\r
120 + if (output_messages)
\r
121 + printf ("%u\n", notmuch_query_count_messages (query));
\r
123 + printf ("%u\n", notmuch_query_count_threads (query));
\r
125 notmuch_query_destroy (query);
\r
126 notmuch_database_close (notmuch);
\r
127 diff --git a/notmuch.1 b/notmuch.1
\r
128 index 15c3147..64114db 100644
\r
131 @@ -372,14 +372,35 @@ section below for details of the supported syntax for <search-terms>.
\r
135 -.BR count " <search-term>..."
\r
136 +.BR count " [options...] <search-term>..."
\r
138 Count messages matching the search terms.
\r
140 -The number of matching messages is output to stdout.
\r
141 +The number of matching messages (or threads) is output to stdout.
\r
143 -With no search terms, a count of all messages in the database will be
\r
145 +With no search terms, a count of all messages (or threads) in the database will
\r
148 +Supported options for
\r
153 +.B \-\-output=(messages|threads)
\r
159 +Output the number of matching messages. This is the default.
\r
165 +Output the number of matching threads.
\r
171 diff --git a/notmuch.c b/notmuch.c
\r
172 index 601ffad..0a4ffe9 100644
\r
175 @@ -328,12 +328,24 @@ static command_t commands[] = {
\r
176 "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
177 "\tterms syntax." },
\r
178 { "count", notmuch_count_command,
\r
179 - "<search-terms> [...]",
\r
180 + "[options...] <search-terms> [...]",
\r
181 "Count messages matching the search terms.",
\r
182 - "\tThe number of matching messages is output to stdout.\n"
\r
183 + "\tThe number of matching messages (or threads) is output to stdout.\n"
\r
185 + "\tWith no search terms, a count of all messages (or threads) in\n"
\r
186 + "\tthe database will be displayed.\n"
\r
188 + "\tSupported options for count include:\n"
\r
190 + "\t--output=(messages|threads)\n"
\r
192 + "\t\tmessages (default)\n"
\r
194 + "\t\tOutput the number of matching messages.\n"
\r
198 - "\tWith no search terms, a count of all messages in the database\n"
\r
199 - "\twill be displayed.\n"
\r
200 + "\t\tOutput the number of matching threads.\n"
\r
202 "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
203 "\tterms syntax." },
\r