From 3bae6b020e06a0e19734d69e7559120c814f3e34 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 3 Jun 2012 12:46:09 +0100 Subject: [PATCH] [Patch v7 3/6] cli: make --entire-thread=false work for format=json. --- 14/4c7caaae0c0a47b12f39175d967b0d6bebbe6e | 143 ++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 14/4c7caaae0c0a47b12f39175d967b0d6bebbe6e diff --git a/14/4c7caaae0c0a47b12f39175d967b0d6bebbe6e b/14/4c7caaae0c0a47b12f39175d967b0d6bebbe6e new file mode 100644 index 000000000..e0ca698f0 --- /dev/null +++ b/14/4c7caaae0c0a47b12f39175d967b0d6bebbe6e @@ -0,0 +1,143 @@ +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 E2E95431FCB + for ; Sun, 3 Jun 2012 04:46:27 -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 Fot8Hm9CiQ05 for ; + Sun, 3 Jun 2012 04:46:26 -0700 (PDT) +Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com + [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 8F8F1431FBD + for ; Sun, 3 Jun 2012 04:46:24 -0700 (PDT) +Received: by wibhj6 with SMTP id hj6so1550539wib.2 + for ; Sun, 03 Jun 2012 04:46:23 -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=/n45GEHGLcfsqfBVT4i6/j+rh6VaZHY5XiDtZeEDCWo=; + b=wJ/+tqllySOsbhgcygxLrYXmBNdggIT2fevPBbUN/Hg1zW9Z4HMjTtVz0QjWtorNwM + L3URfoET4WKg98Vl2LOMm86GyCaaMWSer3zyLPeuxfMn0AyhEBsYWgs83gxGSYhjuIde + MhNT0ZuQMwNjOmmTMR8Cf+xeVilms1AH3CILchjnQAG1wZyxZHDM0YqXdhGobSaObEtD + wda0UuyLKFyhKPfem2rVrvbjPmjs840IUvLAWl6o96sfT9Mc0lSNqD8m0yaZyZDQNx7J + SBcEdep7fbkasVISdC4rXh8DWplKpRIij6MviCbVAkjBX8CJg1bYsJWESn20Ad8hlwJ6 + ducw== +Received: by 10.216.218.219 with SMTP id k69mr7293705wep.123.1338723983330; + Sun, 03 Jun 2012 04:46:23 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + ez4sm12140019wid.3.2012.06.03.04.46.21 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 03 Jun 2012 04:46:22 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v7 3/6] cli: make --entire-thread=false work for format=json. +Date: Sun, 3 Jun 2012 12:46:09 +0100 +Message-Id: <1338723972-13063-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1338723972-13063-1-git-send-email-markwalters1009@gmail.com> +References: <1338723972-13063-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, 03 Jun 2012 11:46:28 -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 | 27 +++++++++++++++++++++++++-- + 1 files changed, 25 insertions(+), 2 deletions(-) + +diff --git a/notmuch-show.c b/notmuch-show.c +index 97da5cc..61e19b0 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,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; +@@ -1059,6 +1069,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; ++ + if (params.decrypt || verify) { + #ifdef GMIME_ATLEAST_26 + /* TODO: GMimePasswordRequestFunc */ +-- +1.7.9.1 + -- 2.26.2