[PATCH v6 3/6] cli: make --entire-thread=false work for format=json.
Mark Walters
markwalters1009 at gmail.com
Sun May 27 01:22:23 PDT 2012
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 | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/notmuch-show.c b/notmuch-show.c
index 97da5cc..4e2965e 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -981,6 +981,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,
@@ -1000,6 +1006,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
notmuch_bool_t verify = FALSE;
int exclude = EXCLUDE_TRUE;
+ int entire_thread = ENTIRE_THREAD_DEFAULT;
notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -1012,8 +1019,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.decrypt, "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
{ 0, 0, 0, 0, 0 }
@@ -1036,7 +1047,9 @@ 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;
+ /* JSON defaults to entire-thread TRUE */
+ if (entire_thread == ENTIRE_THREAD_DEFAULT)
+ entire_thread = ENTIRE_THREAD_TRUE;
break;
case NOTMUCH_FORMAT_TEXT:
format = &format_text;
@@ -1058,6 +1071,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
params.raw = TRUE;
break;
}
+ /* Default is entire-thread = FALSE except for format=json which
+ * is dealt with above. */
+ if (entire_thread == ENTIRE_THREAD_DEFAULT)
+ entire_thread = ENTIRE_THREAD_FALSE;
+
+ if (entire_thread == ENTIRE_THREAD_TRUE)
+ params.entire_thread = TRUE;
+ else
+ params.entire_thread = FALSE;
if (params.decrypt || verify) {
#ifdef GMIME_ATLEAST_26
--
1.7.9.1
More information about the notmuch
mailing list