Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / df / a8ed68dd844acc96ef48a017a23c0d8d248beb
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 065AA429E31\r
6         for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 13:25:30 -0700 (PDT)\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 Z2bOdaxCu83s for <notmuch@notmuchmail.org>;\r
17         Fri,  4 Nov 2011 13:25:28 -0700 (PDT)\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 959C2429E2F\r
22         for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 13:25:27 -0700 (PDT)\r
23 Received: by mail-fx0-f53.google.com with SMTP id n15so52582faa.26\r
24         for <notmuch@notmuchmail.org>; Fri, 04 Nov 2011 13:25:27 -0700 (PDT)\r
25 Received: by 10.223.76.66 with SMTP id b2mr27329292fak.15.1320438327178;\r
26         Fri, 04 Nov 2011 13:25:27 -0700 (PDT)\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 l26sm18277004fad.17.2011.11.04.13.25.25\r
30         (version=SSLv3 cipher=OTHER); Fri, 04 Nov 2011 13:25:26 -0700 (PDT)\r
31 From: Jani Nikula <jani@nikula.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v3 4/7] cli: add support for --output parameter in notmuch\r
34         count\r
35 Date: Fri,  4 Nov 2011 22:25:12 +0200\r
36 Message-Id:\r
37  <9bb08f8ab40e14b28137ea7a4d592d587efce0bc.1320349030.git.jani@nikula.org>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <cover.1320349030.git.jani@nikula.org>\r
40 References: <cover.1320349030.git.jani@nikula.org>\r
41 In-Reply-To: <cover.1320349030.git.jani@nikula.org>\r
42 References: <cover.1320349030.git.jani@nikula.org>\r
43 Cc: amdragon@mit.edu\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Fri, 04 Nov 2011 20:25:30 -0000\r
57 \r
58 Add support for --output=messages (which remains the default) and\r
59 --output=threads to notmuch count.\r
60 \r
61 Signed-off-by: Jani Nikula <jani@nikula.org>\r
62 ---\r
63  notmuch-count.c |   18 ++++++++++++++++--\r
64  1 files changed, 16 insertions(+), 2 deletions(-)\r
65 \r
66 diff --git a/notmuch-count.c b/notmuch-count.c\r
67 index a35be40..09b413e 100644\r
68 --- a/notmuch-count.c\r
69 +++ b/notmuch-count.c\r
70 @@ -29,6 +29,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
71      notmuch_query_t *query;\r
72      char *query_str;\r
73      int i;\r
74 +    notmuch_bool_t output_messages = TRUE;\r
75  \r
76      argc--; argv++; /* skip subcommand argument */\r
77  \r
78 @@ -37,7 +38,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
79             i++;\r
80             break;\r
81         }\r
82 -       {\r
83 +       if (STRNCMP_LITERAL (argv[i], "--output=") == 0) {\r
84 +           const char *opt = argv[i] + sizeof ("--output=") - 1;\r
85 +           if (strcmp (opt, "threads") == 0) {\r
86 +               output_messages = FALSE;\r
87 +           } else if (strcmp (opt, "messages") == 0) {\r
88 +               output_messages = TRUE;\r
89 +           } else {\r
90 +               fprintf (stderr, "Invalid value for --output: %s\n", opt);\r
91 +               return 1;\r
92 +           }\r
93 +       } else {\r
94             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
95             return 1;\r
96         }\r
97 @@ -71,7 +82,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
98         return 1;\r
99      }\r
100  \r
101 -    printf ("%u\n", notmuch_query_count_messages(query));\r
102 +    if (output_messages)\r
103 +       printf ("%u\n", notmuch_query_count_messages(query));\r
104 +    else\r
105 +       printf ("%u\n", notmuch_query_count_threads(query));\r
106  \r
107      notmuch_query_destroy (query);\r
108      notmuch_database_close (notmuch);\r
109 -- \r
110 1.7.5.4\r
111 \r