From: Austin Clements Date: Sun, 2 Dec 2012 02:39:54 +0000 (+1900) Subject: [PATCH 02/10] search: Support --use-schema X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=65fab32298a87606439f9af6c5762470215b1f18;p=notmuch-archives.git [PATCH 02/10] search: Support --use-schema --- diff --git a/a0/72c57a1fe42f9bda8500d7b0af54cf0a8a2723 b/a0/72c57a1fe42f9bda8500d7b0af54cf0a8a2723 new file mode 100644 index 000000000..b80cb313a --- /dev/null +++ b/a0/72c57a1fe42f9bda8500d7b0af54cf0a8a2723 @@ -0,0 +1,153 @@ +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 1B0F4431FC7 + 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 RoMxAGyO8i8r 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 410F3431FAF + for ; Sat, 1 Dec 2012 18:40:13 -0800 (PST) +X-AuditID: 12074424-b7fe06d0000008f0-32-50babf8cc353 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 68.06.02288.C8FBAB05; Sat, 1 Dec 2012 21:40:12 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eCqo013712; + 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 qB22e6pS025595 + (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-0000xT-R5; Sat, 01 Dec 2012 21:40:05 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 02/10] search: Support --use-schema +Date: Sat, 1 Dec 2012 21:39:54 -0500 +Message-Id: <1354416002-3557-2-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+NgFlrHIsWRmVeSWpSXmKPExsUixCmqrNuzf1eAQfNdeYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoErY+7GgoKVIhXn525jbmBcItDFyMEhIWAiceyNexcjJ5ApJnHh + 3nq2LkYuDiGBfYwS57vfMEE46xklDux+BpV5yCRx5uQ/ZghnLqPE0kN7mED62QQ0JLbtX84I + YosISEvsvDubFWQFs4CaxJ8uFRBTWMBY4vLrRBCTRUBVov+/Dkgxr4C9xOl9zWwQRyhKdD+b + wAZSwingILGimwckLARU8v/3NbYJjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zrr5WaW + 6KWmlG5iBAULu4vKDsbmQ0qHGAU4GJV4eCPn7AoQYk0sK67MPcQoycGkJMp7ZQdQiC8pP6Uy + I7E4I76oNCe1+BCjBAezkggviwlQjjclsbIqtSgfJiXNwaIkzns95aa/kEB6YklqdmpqQWoR + TFaGg0NJgvfyXqBGwaLU9NSKtMycEoQ0EwcnyHAeoOEZIDW8xQWJucWZ6RD5U4yKUuK8USAJ + AZBERmkeXC8sml8xigO9IswrsA+oigeYCOC6XwENZgIa/GbZdpDBJYkIKakGRpm317ZFTlp9 + cU/t/0f9LYmmvjKl/sqvuSyqbT2v3OAK+aemd3R6cPlhQ8XlJx3nXwk0d/zctr7npWCjQoLt + 5Yu1kVPqOxb++Jfzvf7ssqwj7bl6X33TKjJ/7b5lcsH5xeeyeN+PP6aLyPY4O4bkKp7MNdtg + YmMpo6qfrvR5mchRb/XAmN3PlFiKMxINtZiLihMBYmPGYcECAAA= +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-search.1 | 20 ++++++++++++++++++++ + notmuch-client.h | 2 ++ + notmuch-search.c | 3 +++ + 3 files changed, 25 insertions(+) + +diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 +index 6ccd3b8..79dc1fe 100644 +--- a/man/man1/notmuch-search.1 ++++ b/man/man1/notmuch-search.1 +@@ -32,6 +32,15 @@ Presents the results in either JSON or plain-text (default). + + .RS 4 + .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 4 ++.TP 4 + .B \-\-output=(summary|threads|messages|files|tags) + + .RS 4 +@@ -125,6 +134,17 @@ In this case all matching threads are returned but the "match count" + is the number of matching non-excluded messages in the thread. + .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 14e7363..95c4dd7 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -140,6 +140,8 @@ chomp_newline (char *str) + * "current" version is consistent across all parts of the schema. + */ + #define NOTMUCH_SCHEMA_CUR 1 ++/* The minimum schema version supported by the "search" command. */ ++#define NOTMUCH_SCHEMA_SEARCH 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-search.c b/notmuch-search.c +index 830c4e4..477f9eb 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -317,6 +317,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, + { "text", NOTMUCH_FORMAT_TEXT }, + { 0, 0 } } }, ++ { NOTMUCH_OPT_INT, ¬much_schema_version, "use-schema", 0, 0 }, + { NOTMUCH_OPT_KEYWORD, &output, "output", 'o', + (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY }, + { "threads", OUTPUT_THREADS }, +@@ -352,6 +353,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) + INTERNAL_ERROR("no output format selected"); + } + ++ notmuch_exit_if_unsupported_schema ("search", NOTMUCH_SCHEMA_SEARCH); ++ + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; +-- +1.7.10.4 +