[PATCH 1/2] cli/tag: add --output={none,lastmod} argument

Subject: [PATCH 1/2] cli/tag: add --output={none,lastmod} argument

Date: Thu, 27 Jan 2022 19:07:39 -0400

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


This commit only changes the command line parsing, no new output is
added.
---
 notmuch-tag.c        | 10 ++++++++++
 test/T150-tagging.sh | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/notmuch-tag.c b/notmuch-tag.c
index 71ff06bf..c6ac51d2 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -22,6 +22,11 @@
 #include "tag-util.h"
 #include "string-util.h"
 
+typedef enum {
+    OUTPUT_NONE	= 0,
+    OUTPUT_LASTMOD	= 1 << 0,
+} output_t;
+
 static volatile sig_atomic_t interrupted;
 
 static void
@@ -228,6 +233,7 @@ notmuch_tag_command (notmuch_database_t *notmuch, int argc, char *argv[])
     const char *input_file_name = NULL;
     int opt_index;
     int ret;
+    int output = OUTPUT_NONE;
     notmuch_bool_t synchronize_flags;
 
     /* Set up our handler for SIGINT */
@@ -240,6 +246,10 @@ notmuch_tag_command (notmuch_database_t *notmuch, int argc, char *argv[])
     notmuch_opt_desc_t options[] = {
 	{ .opt_bool = &batch, .name = "batch" },
 	{ .opt_string = &input_file_name, .name = "input" },
+	{ .opt_keyword = &output, .name = "output", .keywords =
+	      (notmuch_keyword_t []){ { "none", OUTPUT_NONE },
+				      { "lastmod", OUTPUT_LASTMOD },
+				      { 0, 0 } } },
 	{ .opt_bool = &remove_all, .name = "remove-all" },
 	{ .opt_inherit = notmuch_shared_options },
 	{ }
diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh
index 1a2fd77e..ce33dade 100755
--- a/test/T150-tagging.sh
+++ b/test/T150-tagging.sh
@@ -48,6 +48,12 @@ test_expect_equal "$output" "\
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"
 
+test_begin_subtest "--output=none"
+output=$(notmuch tag --output=none +tag7 '*' 2>&1)
+notmuch tag -tag7 '*'
+test_expect_equal "$output" ""
+
+
 test_begin_subtest "Remove all"
 notmuch tag --remove-all One
 notmuch tag --remove-all +tag5 +tag6 +unread Two
@@ -124,6 +130,13 @@ notmuch search \* | notmuch_search_sanitize > OUTPUT
 notmuch restore --format=batch-tag < backup.tags
 test_expect_equal_file batch.expected OUTPUT
 
+test_begin_subtest "--input --output=none"
+notmuch dump --format=batch-tag > backup.tags
+notmuch tag --input=batch.in --output=none > OUTPUT
+notmuch search \* | notmuch_search_sanitize >> OUTPUT
+notmuch restore --format=batch-tag < backup.tags
+test_expect_equal_file batch.expected OUTPUT
+
 test_begin_subtest "--batch --input"
 notmuch dump --format=batch-tag > backup.tags
 notmuch tag --batch --input=batch.in
@@ -131,6 +144,13 @@ notmuch search \* | notmuch_search_sanitize > OUTPUT
 notmuch restore --format=batch-tag < backup.tags
 test_expect_equal_file batch.expected OUTPUT
 
+test_begin_subtest "--batch --input --output=none"
+notmuch dump --format=batch-tag > backup.tags
+notmuch tag --batch --input=batch.in --output=none > OUTPUT
+notmuch search \* | notmuch_search_sanitize >> OUTPUT
+notmuch restore --format=batch-tag < backup.tags
+test_expect_equal_file batch.expected OUTPUT
+
 test_begin_subtest "--batch --input --remove-all"
 notmuch dump --format=batch-tag > backup.tags
 notmuch tag +foo +bar -- One
-- 
2.34.1

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: