]> git.cworth.org Git - notmuch/commitdiff
cli: move count to the new --exclude=(true|false|flag) naming scheme.
authorMark Walters <markwalters1009@gmail.com>
Sat, 7 Apr 2012 16:10:04 +0000 (17:10 +0100)
committerDavid Bremner <bremner@debian.org>
Sun, 8 Apr 2012 02:05:18 +0000 (23:05 -0300)
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
notmuch-count.c
test/count

index 35ecc5323497306eb60c6491941188260f757924..d6cbf074fa5f973a6d1dc833869dfe72bfa12cb6 100644 (file)
@@ -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
index 46b76ae1d13b9340da505ff2b8471112f50d6c87..b76690c0d5eb776096c481f2aff6d9fd62a3e728 100644 (file)
@@ -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));
index b97fc06652f33f87fcf3a4d6016b1b28db536695..fd387e541d170a746f987c4583c9c9835878a96b 100755 (executable)
@@ -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