From 60551cf6c225ac473c5569884571dc8711c2debf Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 2 Dec 2012 21:39:56 +1900 Subject: [PATCH] [PATCH 04/10] reply: Support --use-schema --- 0c/9bef9d54ee784df74483eb7c2e4207bae85885 | 156 ++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 0c/9bef9d54ee784df74483eb7c2e4207bae85885 diff --git a/0c/9bef9d54ee784df74483eb7c2e4207bae85885 b/0c/9bef9d54ee784df74483eb7c2e4207bae85885 new file mode 100644 index 000000000..86ae629bc --- /dev/null +++ b/0c/9bef9d54ee784df74483eb7c2e4207bae85885 @@ -0,0 +1,156 @@ +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 6D0D5431FD9 + for ; Sat, 1 Dec 2012 18:40:14 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 mug57YC5HIMn for ; + Sat, 1 Dec 2012 18:40:13 -0800 (PST) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id 7E111431FBC + for ; Sat, 1 Dec 2012 18:40:13 -0800 (PST) +X-AuditID: 12074424-b7fe06d0000008f0-34-50babf8d77b4 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 88.06.02288.D8FBAB05; Sat, 1 Dec 2012 21:40:13 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eCig022863; + Sat, 1 Dec 2012 21:40:12 -0500 +Received: from drake.dyndns.org + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB22e64U025598 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 1 Dec 2012 21:40:10 -0500 (EST) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1TezTR-0000xY-U0; Sat, 01 Dec 2012 21:40:05 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 04/10] reply: Support --use-schema +Date: Sat, 1 Dec 2012 21:39:56 -0500 +Message-Id: <1354416002-3557-4-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu> +References: <1354416002-3557-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nrtu7f1eAwf/1AhbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXxvKn/5kLjolULNo7l7WBcaNAFyMnh4SAicTsCxeZIGwxiQv3 + 1rN1MXJxCAnsY5ToPfQHylnPKPHv0RZGCOchk8S91x+gMnMZJSZcussM0s8moCGxbf9yRhBb + REBaYufd2axdjBwczAJqEn+6VEDCwgJGEjOWbGQGCbMIqErs+lsCEuYVsJeYu2MBO8QVihLd + zyawgZRwCjhIrOjmAQkLAZX8/32NbQIj/wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW65nq5 + mSV6qSmlmxjBIeOisoOx+ZDSIUYBDkYlHt7IObsChFgTy4orcw8xSnIwKYnyXtkBFOJLyk+p + zEgszogvKs1JLT7EKMHBrCTCy2IClONNSaysSi3Kh0lJc7AoifNeT7npLySQnliSmp2aWpBa + BJOV4eBQkuC9vBeoUbAoNT21Ii0zpwQhzcTBCTKcB2h4BkgNb3FBYm5xZjpE/hSjopQ4bxRI + QgAkkVGaB9cLi+lXjOJArwjzCuwDquIBpgO47ldAg5mABr9Zth1kcEkiQkqqgdHAo/HHDWtz + rpbWM37/bhjcWtT7tNHvQpDJuh9rJ/pcDJHMC+9P4mGMXXzx9otPjwNfW+bPuSB6yCrzf1XY + 8f0Hw9/Vfe7p5e0L0ZvqGhJ1Ul7ryaILrFPnLpQMnsgeM+f4Aa8nVap5Wy9X8swSEtdfrfTs + Z/Su+5Hf0uL8lRPqd9+cWii8tVWJpTgj0VCLuag4EQDfJRzIxAIAAA== +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: Sun, 02 Dec 2012 02:40:14 -0000 + +--- + man/man1/notmuch-reply.1 | 21 +++++++++++++++++++++ + notmuch-client.h | 4 ++++ + notmuch-reply.c | 3 +++ + 3 files changed, 28 insertions(+) + +diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1 +index d264060..71ff569 100644 +--- a/man/man1/notmuch-reply.1 ++++ b/man/man1/notmuch-reply.1 +@@ -52,6 +52,16 @@ to create a reply message intelligently. + Only produces In\-Reply\-To, References, To, Cc, and Bcc headers. + .RE + .RE ++ ++.RS ++.TP 4 ++.BR \-\-use-schema=N ++ ++Use the specified structured output schema version. This is intended ++for programs that invoke \fBnotmuch\fR(1) internally. If omitted, the ++latest supported version will be used. ++.RE ++ + .RS + .TP 4 + .BR \-\-reply\-to= ( all | sender ) +@@ -93,6 +103,17 @@ replying to multiple messages at once, but the JSON format does not. + .RE + .RE + ++.SH EXIT STATUS ++ ++This command supports the following special exit status codes ++ ++.TP ++.B 20 ++The requested schema version is too old. ++.TP ++.B 21 ++The requested schema version is too new. ++ + .SH SEE ALSO + + \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1), +diff --git a/notmuch-client.h b/notmuch-client.h +index d931bbf..0eb6b36 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -144,6 +144,10 @@ chomp_newline (char *str) + #define NOTMUCH_SCHEMA_SEARCH 1 + /* The minimum schema version supported by the "show" command. */ + #define NOTMUCH_SCHEMA_SHOW 1 ++/* The minimum schema version supported by the "reply" command. Reply ++ * uses show, so in general this must be >= NOTMUCH_SCHEMA_SHOW. ++ */ ++#define NOTMUCH_SCHEMA_REPLY 1 + + /* The schema version requested by the caller on the command line. If + * no schema version is requested, this should be set to +diff --git a/notmuch-reply.c b/notmuch-reply.c +index e60a264..059a412 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -724,6 +724,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) + { "json", FORMAT_JSON }, + { "headers-only", FORMAT_HEADERS_ONLY }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_INT, ¬much_schema_version, "use-schema", 0, 0 }, + { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r', + (notmuch_keyword_t []){ { "all", TRUE }, + { "sender", FALSE }, +@@ -745,6 +746,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[]) + else + reply_format_func = notmuch_reply_format_default; + ++ notmuch_exit_if_unsupported_schema ("reply", NOTMUCH_SCHEMA_REPLY); ++ + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; +-- +1.7.10.4 + -- 2.26.2