From: Mark Walters Date: Sun, 27 May 2012 08:22:23 +0000 (+0100) Subject: [PATCH v6 3/6] cli: make --entire-thread=false work for format=json. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=1458fb8c7543f16d01b95d84062305062f019d83;p=notmuch-archives.git [PATCH v6 3/6] cli: make --entire-thread=false work for format=json. --- diff --git a/21/b89e73427b522cb3646737ae4ef5fd4233891b b/21/b89e73427b522cb3646737ae4ef5fd4233891b new file mode 100644 index 000000000..995bcee0a --- /dev/null +++ b/21/b89e73427b522cb3646737ae4ef5fd4233891b @@ -0,0 +1,142 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id EBCCF431FBD + for ; Sun, 27 May 2012 01:22:41 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id SBXDOUV1Z7cR for ; + Sun, 27 May 2012 01:22:41 -0700 (PDT) +Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com + [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + EB7BF431FD8 for ; Sun, 27 May 2012 01:22:39 -0700 + (PDT) +Received: by wgbds1 with SMTP id ds1so777392wgb.2 + for ; Sun, 27 May 2012 01:22:38 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=ZJsjAc9yyHPU9+FFZMriEpFc4xZN3E26HSc81htAKhM=; + b=TyPz0nzFRw123iRdpf83HTOXXUEaLTbvkZF7zMhpfejDqgO8PLGTeDcyK7KhYT8fb6 + nBmBb0TtwJV8Zo+gjceWUD1ahwS3gdY8B70zGOwdcMOIsBNc+l4bVmSm0iWTkGYccXyq + gHWy0muB1VlX8/pMW7Fmx9L0SmsauoTB5ci9UqRGw90guAVOI5/H+bJOEDGikMFUvsWX + XBZVHZt/o3B0kpTTeoQc17qiawZY6u1dZcFGfAwwi7HPONP3EkU1+K7OWPii45S7JqTs + wThhO6/v+fzgLgBXEKK6dNIVw9DX7X6JPiu8GfyI717f6CEodflD/6fvIypmBZbgEHpP + COSw== +Received: by 10.180.102.9 with SMTP id fk9mr8951895wib.1.1338106958702; + Sun, 27 May 2012 01:22:38 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + bn9sm11454404wib.5.2012.05.27.01.22.36 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 27 May 2012 01:22:36 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v6 3/6] cli: make --entire-thread=false work for format=json. +Date: Sun, 27 May 2012 09:22:23 +0100 +Message-Id: <1338106946-7611-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1338106946-7611-1-git-send-email-markwalters1009@gmail.com> +References: <1338106946-7611-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 27 May 2012 08:22:42 -0000 + +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 +