unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 02/10] search: Support --use-schema
Date: Sat,  1 Dec 2012 21:39:54 -0500	[thread overview]
Message-ID: <1354416002-3557-2-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>

---
 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, &notmuch_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

  reply	other threads:[~2012-12-02  2:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-02  2:39 [PATCH 01/10] cli: Framework for structured output versioning Austin Clements
2012-12-02  2:39 ` Austin Clements [this message]
2012-12-02  2:39 ` [PATCH 03/10] show: Support --use-schema Austin Clements
2012-12-02  2:39 ` [PATCH 04/10] reply: " Austin Clements
2012-12-02  2:39 ` [PATCH 05/10] test: Sanity tests for --use-schema argument Austin Clements
2012-12-02  2:39 ` [PATCH 06/10] emacs: Fix bug in resynchronizing after a JSON parse error Austin Clements
2012-12-08  8:32   ` Mark Walters
2012-12-02  2:39 ` [PATCH 07/10] emacs: Use --use-schema for search Austin Clements
2012-12-08  8:48   ` Mark Walters
2012-12-13  1:43     ` Austin Clements
2012-12-13 11:00       ` Mark Walters
2012-12-02  2:40 ` [PATCH 08/10] emacs: Factor out synchronous notmuch JSON invocations Austin Clements
2012-12-02  2:40 ` [PATCH 09/10] emacs: Improve error handling for notmuch-call-notmuch-json Austin Clements
2012-12-02  2:40 ` [PATCH 10/10] emacs: Use --use-schema for show and reply Austin Clements
2012-12-03  0:58 ` [PATCH 00/10] CLI output versioning Austin Clements
2012-12-08  9:29   ` Mark Walters
2012-12-13  1:46     ` Austin Clements

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=1354416002-3557-2-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --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).