[PATCH v3 2/6] cli: move count to the new --exclude=(true|false|flag) naming scheme.
authorMark Walters <markwalters1009@gmail.com>
Fri, 6 Apr 2012 12:49:07 +0000 (13:49 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:04 +0000 (09:46 -0800)
8b/692045c41bf30a6a3d30ca1d3bc20fa264c51a [new file with mode: 0644]

diff --git a/8b/692045c41bf30a6a3d30ca1d3bc20fa264c51a b/8b/692045c41bf30a6a3d30ca1d3bc20fa264c51a
new file mode 100644 (file)
index 0000000..d730bb7
--- /dev/null
@@ -0,0 +1,165 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1EB3B429E29\r
+       for <notmuch@notmuchmail.org>; Fri,  6 Apr 2012 05:49:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id nnzT1aCQwuEX for <notmuch@notmuchmail.org>;\r
+       Fri,  6 Apr 2012 05:49:21 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id DB3A9431FD6\r
+       for <notmuch@notmuchmail.org>; Fri,  6 Apr 2012 05:49:17 -0700 (PDT)\r
+Received: by werm13 with SMTP id m13so1667174wer.26\r
+       for <notmuch@notmuchmail.org>; Fri, 06 Apr 2012 05:49:16 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=yq8Vk74zuiGLhnHZbw3u4pLV1o6O6YCaUEmj30DXz3o=;\r
+       b=gIj2UGIzaZdqM9c7urW0fSRXMhX1n8mMPwQ04+UZDZWKKGJrsHY/8LILQm2bG9NK8d\r
+       gTvZ8D7Dyi/8t6m3Dvwxw9t+Ck0ezyomhG56rZ0IRGwBwcpdigQDkcHv+wnE/hfLBZ0f\r
+       WKFXize6fBg7uOKd6yzPBPjkGtCn/73EWAdy+AA3kSSKADzZSZF9WPFzriqKs9Xn4d7F\r
+       /10VNYCH3SvzSeDjnR9i4gLDGu7QPhPSHLeSnJ86JFcXOdBdF2VzNq8Wcm78q2aV4jCp\r
+       V3hgGZijTYYLaAcvwqqbq+u8+nsVnqCPALd6ev475M6KsB8H2Vmhtukbb5GAeZOzs4HA\r
+       DRwg==\r
+Received: by 10.180.85.70 with SMTP id f6mr19775492wiz.5.1333716556639;\r
+       Fri, 06 Apr 2012 05:49:16 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ fn2sm10217723wib.0.2012.04.06.05.49.15        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 06 Apr 2012 05:49:16 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 2/6] cli: move count to the new --exclude=(true|false|flag)\r
+       naming scheme.\r
+Date: Fri,  6 Apr 2012 13:49:07 +0100\r
+Message-Id: <1333716551-29153-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1333716551-29153-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1333716551-29153-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 06 Apr 2012 12:49:24 -0000\r
+\r
+Move the option --no-exclude to the --exclude= scheme. Since there is\r
+no way to flag messages only true and false are implemented. Note\r
+that, for consistency with other commands, this is implemented as a\r
+keyword option rather than a boolean option.\r
+---\r
+ man/man1/notmuch-count.1 |    5 +++--\r
+ notmuch-count.c          |   17 ++++++++++++-----\r
+ test/count               |    4 ++--\r
+ 3 files changed, 17 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1\r
+index 35ecc53..d6cbf07 100644\r
+--- a/man/man1/notmuch-count.1\r
++++ b/man/man1/notmuch-count.1\r
+@@ -41,9 +41,10 @@ Output the number of matching threads.\r
+ \r
+ .RS 4\r
+ .TP 4\r
+-.BR \-\-no\-exclude\r
++.BR \-\-exclude=(true|false)\r
+ \r
+-Do not exclude the messages matching search.exclude_tags in the config file.\r
++Specify whether to omit messages matching search.tag_exclude from the\r
++count (the default) or not.\r
+ .RE\r
+ .RE\r
+ .RE\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 46b76ae..b76690c 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -26,6 +26,12 @@ enum {\r
+     OUTPUT_MESSAGES,\r
+ };\r
+ \r
++/* The following is to allow future options to be added more easily */\r
++enum {\r
++    EXCLUDE_TRUE,\r
++    EXCLUDE_FALSE,\r
++};\r
++\r
+ int\r
+ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+ {\r
+@@ -35,7 +41,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+     char *query_str;\r
+     int opt_index;\r
+     int output = OUTPUT_MESSAGES;\r
+-    notmuch_bool_t no_exclude = FALSE;\r
++    int exclude = EXCLUDE_TRUE;\r
+     unsigned int i;\r
+ \r
+     notmuch_opt_desc_t options[] = {\r
+@@ -43,7 +49,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+         (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },\r
+                                 { "messages", OUTPUT_MESSAGES },\r
+                                 { 0, 0 } } },\r
+-      { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
++      { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
++        (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
++                                { "false", EXCLUDE_FALSE },\r
++                                { 0, 0 } } },\r
+       { 0, 0, 0, 0, 0 }\r
+     };\r
+ \r
+@@ -78,7 +87,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+       return 1;\r
+     }\r
+ \r
+-    if (!no_exclude) {\r
++    if (exclude == EXCLUDE_TRUE) {\r
+       const char **search_exclude_tags;\r
+       size_t search_exclude_tags_length;\r
+ \r
+@@ -88,8 +97,6 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
+           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
+     }\r
+ \r
+-    notmuch_query_set_omit_excluded_messages (query, TRUE);\r
+-\r
+     switch (output) {\r
+     case OUTPUT_MESSAGES:\r
+       printf ("%u\n", notmuch_query_count_messages (query));\r
+diff --git a/test/count b/test/count\r
+index b97fc06..fd387e5 100755\r
+--- a/test/count\r
++++ b/test/count\r
+@@ -53,9 +53,9 @@ test_expect_equal \\r
+     "1" \\r
+     "`notmuch count subject:deleted and tag:deleted`"\r
+ \r
+-test_begin_subtest "count \"deleted\" messages, with --no-exclude"\r
++test_begin_subtest "count \"deleted\" messages, --exclude=false"\r
+ test_expect_equal \\r
+     "3" \\r
+-    "`notmuch count --no-exclude subject:deleted`"\r
++    "`notmuch count --exclude=false subject:deleted`"\r
+ \r
+ test_done\r
+-- \r
+1.7.9.1\r
+\r