Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 21 / bb0928508a20e4fa3f097bb01213a67da439a7
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 0B90F429E21\r
6         for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 11:49:07 -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
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \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 YfGlU2mUuTvE for <notmuch@notmuchmail.org>;\r
17         Sun, 13 Nov 2011 11:49:05 -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 448A2429E38\r
22         for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 11:49:01 -0800 (PST)\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so6225076bka.26\r
24         for <notmuch@notmuchmail.org>; Sun, 13 Nov 2011 11:49:00 -0800 (PST)\r
25 Received: by 10.204.132.71 with SMTP id a7mr16316412bkt.93.1321213740775;\r
26         Sun, 13 Nov 2011 11:49:00 -0800 (PST)\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
28         [80.220.92.23])\r
29         by mx.google.com with ESMTPS id z15sm27183326bkv.4.2011.11.13.11.48.58\r
30         (version=SSLv3 cipher=OTHER); Sun, 13 Nov 2011 11:48:59 -0800 (PST)\r
31 From: Jani Nikula <jani@nikula.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v5 4/6] cli: add support for --output parameter in notmuch\r
34         count\r
35 Date: Sun, 13 Nov 2011 21:48:38 +0200\r
36 Message-Id:\r
37  <fe54c7f0c33d3d8694b57a05d4462229fe256605.1321212673.git.jani@nikula.org>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <cover.1321212673.git.jani@nikula.org>\r
40 References: <cover.1321212673.git.jani@nikula.org>\r
41 In-Reply-To: <cover.1321212673.git.jani@nikula.org>\r
42 References: <cover.1321212673.git.jani@nikula.org>\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\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 19:49:08 -0000\r
56 \r
57 Add support for --output=messages (which remains the default) and\r
58 --output=threads to notmuch count.\r
59 \r
60 Signed-off-by: Jani Nikula <jani@nikula.org>\r
61 ---\r
62  NEWS            |    5 +++++\r
63  notmuch-count.c |   18 ++++++++++++++++--\r
64  notmuch.1       |   29 +++++++++++++++++++++++++----\r
65  3 files changed, 46 insertions(+), 6 deletions(-)\r
66 \r
67 diff --git a/NEWS b/NEWS\r
68 index abc749a..78434d9 100644\r
69 --- a/NEWS\r
70 +++ b/NEWS\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
74  \r
75 +Add "notmuch count --output" option\r
76 +\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
79 +\r
80  Notmuch 0.9 (2011-10-01)\r
81  ========================\r
82  \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
89      char *query_str;\r
90      int i;\r
91 +    notmuch_bool_t output_messages = TRUE;\r
92  \r
93      argc--; argv++; /* skip subcommand argument */\r
94  \r
95 @@ -37,7 +38,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
96             i++;\r
97             break;\r
98         }\r
99 -       {\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
106 +           } else {\r
107 +               fprintf (stderr, "Invalid value for --output: %s\n", opt);\r
108 +               return 1;\r
109 +           }\r
110 +       } else {\r
111             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
112             return 1;\r
113         }\r
114 @@ -71,7 +82,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
115         return 1;\r
116      }\r
117  \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
121 +    else\r
122 +       printf ("%u\n", notmuch_query_count_threads (query));\r
123  \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 15c3147..64114db 100644\r
128 --- a/notmuch.1\r
129 +++ b/notmuch.1\r
130 @@ -372,14 +372,35 @@ section below for details of the supported syntax for <search-terms>.\r
131  .RE\r
132  .RS 4\r
133  .TP 4\r
134 -.BR count " <search-term>..."\r
135 +.BR count " [options...] <search-term>..."\r
136  \r
137  Count messages matching the search terms.\r
138  \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
141  \r
142 -With no search terms, a count of all messages in the database will be\r
143 -displayed.\r
144 +With no search terms, a count of all messages (or threads) in the database will\r
145 +be displayed.\r
146 +\r
147 +Supported options for\r
148 +.B count\r
149 +include\r
150 +.RS 4\r
151 +.TP 4\r
152 +.B \-\-output=(messages|threads)\r
153 +\r
154 +.RS 4\r
155 +.TP 4\r
156 +.B messages\r
157 +\r
158 +Output the number of matching messages. This is the default.\r
159 +.RE\r
160 +.RS 4\r
161 +.TP 4\r
162 +.B threads\r
163 +\r
164 +Output the number of matching threads.\r
165 +.RE\r
166 +.RE\r
167  .RE\r
168  .RE\r
169  \r
170 -- \r
171 1.7.5.4\r
172 \r