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 E6A91429E36
\r
6 for <notmuch@notmuchmail.org>; Sun, 6 Nov 2011 13:47:35 -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 PDajAT5nOLqP for <notmuch@notmuchmail.org>;
\r
17 Sun, 6 Nov 2011 13:47:33 -0800 (PST)
\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com
\r
19 [209.85.161.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 739C9429E32
\r
22 for <notmuch@notmuchmail.org>; Sun, 6 Nov 2011 13:47:33 -0800 (PST)
\r
23 Received: by mail-fx0-f53.google.com with SMTP id n15so1762114faa.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 06 Nov 2011 13:47:33 -0800 (PST)
\r
25 Received: by 10.223.75.150 with SMTP id y22mr41894084faj.29.1320616053063;
\r
26 Sun, 06 Nov 2011 13:47:33 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id j5sm28494119faf.14.2011.11.06.13.47.31
\r
30 (version=SSLv3 cipher=OTHER); Sun, 06 Nov 2011 13:47:32 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH v4 4/6] cli: add support for --output parameter in notmuch
\r
35 Date: Sun, 6 Nov 2011 23:47:13 +0200
\r
37 <f499964b78d509223c531f1c424e98ed821fd602.1320615322.git.jani@nikula.org>
\r
38 X-Mailer: git-send-email 1.7.5.4
\r
39 In-Reply-To: <cover.1320615322.git.jani@nikula.org>
\r
40 References: <cover.1320615322.git.jani@nikula.org>
\r
41 In-Reply-To: <cover.1320615322.git.jani@nikula.org>
\r
42 References: <cover.1320615322.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, 06 Nov 2011 21:47:36 -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 3 files changed, 46 insertions(+), 6 deletions(-)
\r
67 diff --git a/NEWS b/NEWS
\r
68 index bfdba7b..009811f 100644
\r
71 @@ -28,6 +28,11 @@ Add "notmuch search" --first and --maxitems options
\r
72 The search command now takes options --first=[-]N and --maxitems=N to limit
\r
73 the number of results shown.
\r
75 +Add "notmuch count --output" option
\r
77 + The count command is now capable of counting threads in addition to
\r
78 + messages. This is selected using the new --output=(threads|messages) option.
\r
80 Notmuch 0.9 (2011-10-01)
\r
81 ========================
\r
83 diff --git a/notmuch-count.c b/notmuch-count.c
\r
84 index a35be40..20ce334 100644
\r
85 --- a/notmuch-count.c
\r
86 +++ b/notmuch-count.c
\r
87 @@ -29,6 +29,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
88 notmuch_query_t *query;
\r
91 + notmuch_bool_t output_messages = TRUE;
\r
93 argc--; argv++; /* skip subcommand argument */
\r
95 @@ -37,7 +38,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
100 + if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {
\r
101 + const char *opt = argv[i] + sizeof ("--output=") - 1;
\r
102 + if (strcmp (opt, "threads") == 0) {
\r
103 + output_messages = FALSE;
\r
104 + } else if (strcmp (opt, "messages") == 0) {
\r
105 + output_messages = TRUE;
\r
107 + fprintf (stderr, "Invalid value for --output: %s\n", opt);
\r
111 fprintf (stderr, "Unrecognized option: %s\n", argv[i]);
\r
114 @@ -71,7 +82,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
\r
118 - printf ("%u\n", notmuch_query_count_messages(query));
\r
119 + if (output_messages)
\r
120 + printf ("%u\n", notmuch_query_count_messages (query));
\r
122 + printf ("%u\n", notmuch_query_count_threads (query));
\r
124 notmuch_query_destroy (query);
\r
125 notmuch_database_close (notmuch);
\r
126 diff --git a/notmuch.1 b/notmuch.1
\r
127 index c97334c..f53c183 100644
\r
130 @@ -374,14 +374,35 @@ section below for details of the supported syntax for <search-terms>.
\r
134 -.BR count " <search-term>..."
\r
135 +.BR count " [options...] <search-term>..."
\r
137 Count messages matching the search terms.
\r
139 -The number of matching messages is output to stdout.
\r
140 +The number of matching messages (or threads) is output to stdout.
\r
142 -With no search terms, a count of all messages in the database will be
\r
144 +With no search terms, a count of all messages (or threads) in the database will
\r
147 +Supported options for
\r
152 +.B \-\-output=(threads|messages)
\r
158 +Output the number of matching threads.
\r
164 +Output the number of matching messages. This is the default.
\r