From 3b0e8f3ddbe301d9911b41d13cb0e3397f936337 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 7 Apr 2012 17:10:04 +0100 Subject: [PATCH] [PATCH v4 2/6] cli: move count to the new --exclude=(true|false|flag) naming scheme. --- 70/bf86a8e430e6755e07fedf8d9b1616c4de4b73 | 165 ++++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 70/bf86a8e430e6755e07fedf8d9b1616c4de4b73 diff --git a/70/bf86a8e430e6755e07fedf8d9b1616c4de4b73 b/70/bf86a8e430e6755e07fedf8d9b1616c4de4b73 new file mode 100644 index 000000000..eba787074 --- /dev/null +++ b/70/bf86a8e430e6755e07fedf8d9b1616c4de4b73 @@ -0,0 +1,165 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id EC465431FD2 + for ; Sat, 7 Apr 2012 09:10:21 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id msy0KcbF6WXz for ; + Sat, 7 Apr 2012 09:10:20 -0700 (PDT) +Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com + [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 6E8C8431FBC for ; Sat, 7 Apr 2012 09:10:20 -0700 + (PDT) +Received: by wgbdt14 with SMTP id dt14so822285wgb.2 + for ; Sat, 07 Apr 2012 09:10:19 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=yq8Vk74zuiGLhnHZbw3u4pLV1o6O6YCaUEmj30DXz3o=; + b=gKfXYDLQGyX4a54uTp6w9Axbb36mBhZXj1D7ORWmpojK3cldQLbsHDK0MOe6/4lHr6 + hKe9zIN3r/y83ZrYKD7mfqwGdM4+h5qWgcnGH2dbjfKhCpZiWOtm6tOPmaIQ4Jv1rFQr + 369awzwFuYt8EsGwojwQ0imQMBVSopg+4LVqj+l0lSpsTZ1NWiMEfLSlqn1Mj6yKu2Ar + R7R3qVpU06kHDM1AbzKioud0uFwFHM6zB7Pg1qbxwoTbo7M4jljIEvWqMl/3d7WdM4jm + bbu+VuSz0nxWRxzbCFlsqBpVfJEx0f7ISpLe2eCViPqvr02NGtPKmOaDoVwztMgBu3GP + qgEQ== +Received: by 10.216.85.81 with SMTP id t59mr1042639wee.28.1333815019125; + Sat, 07 Apr 2012 09:10:19 -0700 (PDT) +Received: from localhost (94.197.17.51.threembb.co.uk. [94.197.17.51]) + by mx.google.com with ESMTPS id ca3sm6930586wib.6.2012.04.07.09.10.16 + (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 07 Apr 2012 09:10:18 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 2/6] cli: move count to the new --exclude=(true|false|flag) + naming scheme. +Date: Sat, 7 Apr 2012 17:10:04 +0100 +Message-Id: <1333815008-24668-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1333815008-24668-1-git-send-email-markwalters1009@gmail.com> +References: <1333815008-24668-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 07 Apr 2012 16:10:22 -0000 + +Move the option --no-exclude to the --exclude= scheme. Since there is +no way to flag messages only true and false are implemented. Note +that, for consistency with other commands, this is implemented as a +keyword option rather than a boolean option. +--- + man/man1/notmuch-count.1 | 5 +++-- + notmuch-count.c | 17 ++++++++++++----- + test/count | 4 ++-- + 3 files changed, 17 insertions(+), 9 deletions(-) + +diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1 +index 35ecc53..d6cbf07 100644 +--- a/man/man1/notmuch-count.1 ++++ b/man/man1/notmuch-count.1 +@@ -41,9 +41,10 @@ Output the number of matching threads. + + .RS 4 + .TP 4 +-.BR \-\-no\-exclude ++.BR \-\-exclude=(true|false) + +-Do not exclude the messages matching search.exclude_tags in the config file. ++Specify whether to omit messages matching search.tag_exclude from the ++count (the default) or not. + .RE + .RE + .RE +diff --git a/notmuch-count.c b/notmuch-count.c +index 46b76ae..b76690c 100644 +--- a/notmuch-count.c ++++ b/notmuch-count.c +@@ -26,6 +26,12 @@ enum { + OUTPUT_MESSAGES, + }; + ++/* The following is to allow future options to be added more easily */ ++enum { ++ EXCLUDE_TRUE, ++ EXCLUDE_FALSE, ++}; ++ + int + notmuch_count_command (void *ctx, int argc, char *argv[]) + { +@@ -35,7 +41,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + char *query_str; + int opt_index; + int output = OUTPUT_MESSAGES; +- notmuch_bool_t no_exclude = FALSE; ++ int exclude = EXCLUDE_TRUE; + unsigned int i; + + notmuch_opt_desc_t options[] = { +@@ -43,7 +49,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, + { "messages", OUTPUT_MESSAGES }, + { 0, 0 } } }, +- { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, ++ { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', ++ (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, ++ { "false", EXCLUDE_FALSE }, ++ { 0, 0 } } }, + { 0, 0, 0, 0, 0 } + }; + +@@ -78,7 +87,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + return 1; + } + +- if (!no_exclude) { ++ if (exclude == EXCLUDE_TRUE) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + +@@ -88,8 +97,6 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + } + +- notmuch_query_set_omit_excluded_messages (query, TRUE); +- + switch (output) { + case OUTPUT_MESSAGES: + printf ("%u\n", notmuch_query_count_messages (query)); +diff --git a/test/count b/test/count +index b97fc06..fd387e5 100755 +--- a/test/count ++++ b/test/count +@@ -53,9 +53,9 @@ test_expect_equal \ + "1" \ + "`notmuch count subject:deleted and tag:deleted`" + +-test_begin_subtest "count \"deleted\" messages, with --no-exclude" ++test_begin_subtest "count \"deleted\" messages, --exclude=false" + test_expect_equal \ + "3" \ +- "`notmuch count --no-exclude subject:deleted`" ++ "`notmuch count --exclude=false subject:deleted`" + + test_done +-- +1.7.9.1 + -- 2.26.2