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