[PATCH 2/2] cli: make --entire-thread option notmuch-show.c INT_OR_BOOLEAN

Mark Walters markwalters1009 at gmail.com
Thu Mar 8 14:15:44 PST 2012


Make the --entire-thread option notmuch-show.c
NOTMUCH_OPT_INT_OR_BOOLEAN. In particular this means a caller can turn
off entire-thread (by specifying --entire-thread=0) when format=json.
(This was not previously possible.)
---
 notmuch-show.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 05d51b2..f0c640f 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -985,6 +985,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     const notmuch_show_format_t *format = &format_text;
     notmuch_show_params_t params = { .part = -1 };
     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
+    int entire_thread = -1;
     notmuch_bool_t verify = FALSE;
     notmuch_bool_t no_exclude = FALSE;
 
@@ -996,7 +997,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 				  { "raw", NOTMUCH_FORMAT_RAW },
 				  { 0, 0 } } },
 	{ NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },
-	{ NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },
+	{ NOTMUCH_OPT_INT_OR_BOOLEAN, &entire_thread, "entire-thread", 't', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },
@@ -1020,7 +1021,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     switch (format_sel) {
     case NOTMUCH_FORMAT_JSON:
 	format = &format_json;
-	params.entire_thread = TRUE;
+	if (entire_thread == -1)
+	    entire_thread = 1;
 	break;
     case NOTMUCH_FORMAT_TEXT:
 	format = &format_text;
@@ -1042,6 +1044,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	params.raw = TRUE;
 	break;
     }
+    /* Set default to not entire_thread; JSON case dealt with above */
+    if (entire_thread == -1)
+	entire_thread = 0;
+    params.entire_thread = notmuch_int_to_boolean (entire_thread);
 
     if (params.decrypt || verify) {
 #ifdef GMIME_ATLEAST_26
-- 
1.7.9.1



More information about the notmuch mailing list