From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oOgaB36Z9WGrRwAAgWs5BA (envelope-from ) for ; Sat, 29 Jan 2022 20:46:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CLhUBH6Z9WEUxAAA9RJhRA (envelope-from ) for ; Sat, 29 Jan 2022 20:46:06 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id ADD1140908 for ; Sat, 29 Jan 2022 20:46:00 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 13E735F74B; Sat, 29 Jan 2022 19:45:47 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 1D1BF5F73F for ; Sat, 29 Jan 2022 19:45:44 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 508335FBD6; Sat, 29 Jan 2022 14:45:43 -0500 (EST) Received: (nullmailer pid 2790879 invoked by uid 1000); Sat, 29 Jan 2022 19:45:39 -0000 From: David Bremner 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 Message-Id: <20220129194439.2790761-6-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220129194439.2790761-1-david@tethera.net> References: <20220129194439.2790761-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 6X3KHLLMFOXWUINWVXJTI3Z24DSG33OW X-Message-ID-Hash: 6X3KHLLMFOXWUINWVXJTI3Z24DSG33OW X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643485560; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=HxWt063omZk5RAIzklq098szyBz/t7QqpcJAu4A8HgY=; b=YQMZy5S2q7exR6raJkCpKUlIvxns19n2Dh922EXj0dcF3VgOMy3zyceDUIst/dZ9xZKiM1 xFYFm6ctRub562tkskkxTRg4dsX/P1dDvRqY3dehFrTAmM+TaSilVcCFuC3JG/VkPVoFXP ftuP+Gi7Sk/L43dY5TgBdP9hKiBS0ADXCGqg2X/XTa+3BkxSfbso+m7IYVS25GuK8u5yWG tIER7Kr8qpxCAptF9DFsYGj6rM7hfgLFley8DjNUMdRoh1hf9W7iLTCI/2isx/ezJzKkOS ngTIWYx4B679G2xgPMwjqjs3uuTf9gltvgRr2LbIuR6WGUr8MGPYVtQWma2o4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643485560; a=rsa-sha256; cv=none; b=fc6SAR9OXyGogufeIUJStGl4Y8wohSCRY4wPH/TLdDUnaNBhzmAnU08s0fp+4TT6gSDEsh jbJLQeBlqRNvq7pFCR1tsnbkGQifmfbdrMeZcQCK/Mb69UvT32DjZDI3ldNPTspDGk1XPq qWgLifUIcWy+FJ6dLYotfFxViwF9QZ4RBrsvNuu9zgZKNm5KksZDUytuIybiQd6OIfM6pl 6No3dyrAXOrvpIo9HaLuaZ+4VRdxzPcUpXwYR1h0VgiqsRD1yz4PGg9SnFQ+GCkaSvLBCx T43V0+UBZY6exZKM5e+eTl+Qi8B7KQdeI4P9nPaxybRnqb2tlmFUisN6zTt2hg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.36 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: ADD1140908 X-Spam-Score: -2.36 X-Migadu-Scanner: scn0.migadu.com X-TUID: Z/3Hk+3M7QCW 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