unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [RFC PATCH v2 5/8] cli/tag: add --output={none,lastmod} argument
Date: Sat, 29 Jan 2022 15:44:37 -0400	[thread overview]
Message-ID: <20220129194439.2790761-6-david@tethera.net> (raw)
In-Reply-To: <20220129194439.2790761-1-david@tethera.net>

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

  parent reply	other threads:[~2022-01-29 19:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-29 19:44 v2 undo tag operations in emacs David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 1/8] test: split variable settings to their own file David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 2/8] test/emacs: split out emacs related tests David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 3/8] WIP enable running test_emacs from performance tests David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 4/8] perf-test: inital emacs tests David Bremner
2022-01-29 19:44 ` David Bremner [this message]
2022-01-29 19:44 ` [RFC PATCH v2 6/8] WIP: support tag --output=lastmod David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 7/8] WIP/emacs: keep tag history David Bremner
2022-01-29 19:44 ` [RFC PATCH v2 8/8] WIP: add notmuch-tag-undo David Bremner
2022-02-02 14:34   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220129194439.2790761-6-david@tethera.net \
    --to=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).