[PATCH 0/3] notmuch show argument parsing
authorJani Nikula <jani@nikula.org>
Mon, 6 Feb 2012 19:57:20 +0000 (21:57 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:13 +0000 (09:44 -0800)
d7/4aa7fdd5b670548462c8edc30fd5f3e91ab9b6 [new file with mode: 0644]

diff --git a/d7/4aa7fdd5b670548462c8edc30fd5f3e91ab9b6 b/d7/4aa7fdd5b670548462c8edc30fd5f3e91ab9b6
new file mode 100644 (file)
index 0000000..ff179e4
--- /dev/null
@@ -0,0 +1,208 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 56210431FB6\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Feb 2012 11:57:34 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YMAOLH5fwSJ7 for <notmuch@notmuchmail.org>;\r
+       Mon,  6 Feb 2012 11:57:30 -0800 (PST)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+       [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B9D03431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  6 Feb 2012 11:57:29 -0800 (PST)\r
+Received: by lahd3 with SMTP id d3so3838995lah.26\r
+       for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 11:57:26 -0800 (PST)\r
+Received: by 10.112.26.6 with SMTP id h6mr5230184lbg.6.1328558246792;\r
+       Mon, 06 Feb 2012 11:57:26 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
+       [84.248.80.253])\r
+       by mx.google.com with ESMTPS id mc3sm13757805lab.12.2012.02.06.11.57.24\r
+       (version=SSLv3 cipher=OTHER); Mon, 06 Feb 2012 11:57:25 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 0/3] notmuch show argument parsing\r
+Date: Mon,  6 Feb 2012 21:57:20 +0200\r
+Message-Id: <cover.1328558175.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To:\r
+ <df2e9bd7682e9c81e1b205cc1d92a1526cdd1a9b.1328308635.git.jani@nikula.org>\r
+References:\r
+ <df2e9bd7682e9c81e1b205cc1d92a1526cdd1a9b.1328308635.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Feb 2012 19:57:34 -0000\r
+\r
+Hi all, \r
+\r
+v2 addressing Austin's comments in id:"20120206041205.GP10898@mit.edu".\r
+Separate the bool cleanup into a new patch, cleaning up notmuch reply\r
+while at it. No functional changes since v1.\r
+\r
+For reviewing convenience, the diff between v1 and v2 is at the end of\r
+this cover letter.\r
+\r
+BR,\r
+Jani.\r
+\r
+Jani Nikula (3):\r
+  cli: use notmuch_bool_t for boolean fields in notmuch_show_params_t\r
+  cli: convert "notmuch show" to use the new argument parser\r
+  cli: reach previously unreachable cleanup code in "notmuch show"\r
+\r
+ notmuch-client.h |    6 +-\r
+ notmuch-reply.c  |    7 +--\r
+ notmuch-show.c   |  155 +++++++++++++++++++++++++++---------------------------\r
+ 3 files changed, 84 insertions(+), 84 deletions(-)\r
+\r
+-- \r
+1.7.5.4\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index e0eb594..60828aa 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -98,15 +98,15 @@ typedef struct notmuch_show_format {\r
+ } notmuch_show_format_t;\r
+ \r
+ typedef struct notmuch_show_params {\r
+-    int entire_thread;\r
+-    int raw;\r
++    notmuch_bool_t entire_thread;\r
++    notmuch_bool_t raw;\r
+     int part;\r
+ #ifdef GMIME_ATLEAST_26\r
+     GMimeCryptoContext* cryptoctx;\r
+ #else\r
+     GMimeCipherContext* cryptoctx;\r
+ #endif\r
+-    int decrypt;\r
++    notmuch_bool_t decrypt;\r
+ } notmuch_show_params_t;\r
+ \r
+ /* There's no point in continuing when we've detected that we've done\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index f55b1d2..6b244e6 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -661,7 +661,6 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+     notmuch_show_params_t params = { .part = -1 };\r
+     int format = FORMAT_DEFAULT;\r
+     int reply_all = TRUE;\r
+-    notmuch_bool_t decrypt = FALSE;\r
+ \r
+     notmuch_opt_desc_t options[] = {\r
+       { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
+@@ -672,7 +671,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+         (notmuch_keyword_t []){ { "all", TRUE },\r
+                                 { "sender", FALSE },\r
+                                 { 0, 0 } } },\r
+-      { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
++      { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
+       { 0, 0, 0, 0, 0 }\r
+     };\r
+ \r
+@@ -687,7 +686,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+     else\r
+       reply_format_func = notmuch_reply_format_default;\r
+ \r
+-    if (decrypt) {\r
++    if (params.decrypt) {\r
+ #ifdef GMIME_ATLEAST_26\r
+       /* TODO: GMimePasswordRequestFunc */\r
+       params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
+@@ -697,8 +696,8 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+ #endif\r
+       if (params.cryptoctx) {\r
+           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
+-          params.decrypt = TRUE;\r
+       } else {\r
++          params.decrypt = FALSE;\r
+           fprintf (stderr, "Failed to construct gpg context.\n");\r
+       }\r
+ #ifndef GMIME_ATLEAST_26\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index b18e279..c8fbd79 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1068,9 +1068,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+     const notmuch_show_format_t *format = &format_text;\r
+     notmuch_show_params_t params = { .part = -1 };\r
+     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
+-    notmuch_bool_t decrypt = FALSE;\r
+     notmuch_bool_t verify = FALSE;\r
+-    notmuch_bool_t entire_thread = FALSE;\r
+ \r
+     notmuch_opt_desc_t options[] = {\r
+       { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
+@@ -1080,8 +1078,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+                                 { "raw", NOTMUCH_FORMAT_RAW },\r
+                                 { 0, 0 } } },\r
+       { NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },\r
+-      { NOTMUCH_OPT_BOOLEAN, &entire_thread, "entire-thread", 't', 0 },\r
+-      { NOTMUCH_OPT_BOOLEAN, &decrypt, "decrypt", 'd', 0 },\r
++      { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },\r
++      { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
+       { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
+       { 0, 0, 0, 0, 0 }\r
+     };\r
+@@ -1092,8 +1090,6 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+       return 1;\r
+     }\r
+ \r
+-    params.entire_thread = entire_thread;\r
+-\r
+     if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {\r
+       /* if part was requested and format was not specified, use format=raw */\r
+       if (params.part >= 0)\r
+@@ -1105,7 +1101,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+     switch (format_sel) {\r
+     case NOTMUCH_FORMAT_JSON:\r
+       format = &format_json;\r
+-      params.entire_thread = 1;\r
++      params.entire_thread = TRUE;\r
+       break;\r
+     case NOTMUCH_FORMAT_TEXT:\r
+       format = &format_text;\r
+@@ -1123,11 +1119,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+        * output single message, so set part=0 */\r
+       if (params.part < 0)\r
+           params.part = 0;\r
+-      params.raw = 1;\r
++      params.raw = TRUE;\r
+       break;\r
+     }\r
+ \r
+-    if (decrypt || verify) {\r
++    if (params.decrypt || verify) {\r
+ #ifdef GMIME_ATLEAST_26\r
+       /* TODO: GMimePasswordRequestFunc */\r
+       params.cryptoctx = g_mime_gpg_context_new (NULL, "gpg");\r
+@@ -1137,8 +1133,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
+ #endif\r
+       if (params.cryptoctx) {\r
+           g_mime_gpg_context_set_always_trust ((GMimeGpgContext*) params.cryptoctx, FALSE);\r
+-          params.decrypt = decrypt;\r
+       } else {\r
++          params.decrypt = FALSE;\r
+           fprintf (stderr, "Failed to construct gpg context.\n");\r
+       }\r
+ #ifndef GMIME_ATLEAST_26\r