From 15904cde125d317c7e59923104e270c6fbe502f7 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 16 Jun 2012 11:21:44 +0100 Subject: [PATCH] cli: make --entire-thread=false work for format=json. The --entire-thread option in notmuch-show.c defaults to true when format=json. Previously there was no way to turn this off. This patch makes it respect --entire-thread=false. To do this the patch moves the --entire-thread option to be a keyword option using the new command line parsing to allow the existing --entire-thread to keep working. --- notmuch-show.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b0044684..e6eb625d 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -980,6 +980,12 @@ enum { NOTMUCH_FORMAT_RAW }; +enum { + ENTIRE_THREAD_DEFAULT, + ENTIRE_THREAD_TRUE, + ENTIRE_THREAD_FALSE, +}; + /* The following is to allow future options to be added more easily */ enum { EXCLUDE_TRUE, @@ -1005,6 +1011,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; int exclude = EXCLUDE_TRUE; + int entire_thread = ENTIRE_THREAD_DEFAULT; notmuch_opt_desc_t options[] = { { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', @@ -1017,8 +1024,12 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, { "false", EXCLUDE_FALSE }, { 0, 0 } } }, + { NOTMUCH_OPT_KEYWORD, &entire_thread, "entire-thread", 't', + (notmuch_keyword_t []){ { "true", ENTIRE_THREAD_TRUE }, + { "false", ENTIRE_THREAD_FALSE }, + { "", ENTIRE_THREAD_TRUE }, + { 0, 0 } } }, { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, { 0, 0, 0, 0, 0 } @@ -1045,7 +1056,6 @@ 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; break; case NOTMUCH_FORMAT_TEXT: format = &format_text; @@ -1068,6 +1078,19 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) break; } + /* Default is entire-thread = FALSE except for format=json. */ + if (entire_thread == ENTIRE_THREAD_DEFAULT) { + if (format == &format_json) + entire_thread = ENTIRE_THREAD_TRUE; + else + entire_thread = ENTIRE_THREAD_FALSE; + } + + if (entire_thread == ENTIRE_THREAD_TRUE) + params.entire_thread = TRUE; + else + params.entire_thread = FALSE; + config = notmuch_config_open (ctx, NULL, NULL); if (config == NULL) return 1; -- 2.43.0