mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
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.
This commit is contained in:
parent
4d3bfba983
commit
15904cde12
1 changed files with 25 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue