[PATCH 03/10] show: Support --use-schema

Austin Clements amdragon at MIT.EDU
Sat Dec 1 18:39:55 PST 2012


---
 man/man1/notmuch-show.1 |   20 ++++++++++++++++++++
 notmuch-client.h        |    2 ++
 notmuch-show.c          |    3 +++
 3 files changed, 25 insertions(+)

diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1
index 4481f21..e2fd0c2 100644
--- a/man/man1/notmuch-show.1
+++ b/man/man1/notmuch-show.1
@@ -108,6 +108,15 @@ message.
 
 .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 \-\-part=N
 
 Output the single decoded MIME part N of a single message.  The search
@@ -181,6 +190,17 @@ column of output from the
 .B notmuch search
 command.
 
+.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 95c4dd7..d931bbf 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -142,6 +142,8 @@ chomp_newline (char *str)
 #define NOTMUCH_SCHEMA_CUR 1
 /* The minimum schema version supported by the "search" command. */
 #define NOTMUCH_SCHEMA_SEARCH 1
+/* The minimum schema version supported by the "show" command. */
+#define NOTMUCH_SCHEMA_SHOW 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-show.c b/notmuch-show.c
index 2fa2292..9d1f7c7 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1059,6 +1059,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 				  { "mbox", NOTMUCH_FORMAT_MBOX },
 				  { "raw", NOTMUCH_FORMAT_RAW },
 				  { 0, 0 } } },
+	{ NOTMUCH_OPT_INT, &notmuch_schema_version, "use-schema", 0, 0 },
 	{ NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
 	  (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
 				  { "false", EXCLUDE_FALSE },
@@ -1118,6 +1119,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	break;
     }
 
+    notmuch_exit_if_unsupported_schema ("show", NOTMUCH_SCHEMA_SHOW);
+
     /* Default is entire-thread = FALSE except for format=json. */
     if (entire_thread == ENTIRE_THREAD_DEFAULT) {
 	if (format == &format_json)
-- 
1.7.10.4



More information about the notmuch mailing list