From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 6AB566DE0C97 for ; Wed, 11 Oct 2017 07:35:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gp0Ae_rXvQps for ; Wed, 11 Oct 2017 07:35:16 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id D05C26DE112B for ; Wed, 11 Oct 2017 07:35:16 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1e2I2c-0004oj-GR for notmuch@notmuchmail.org; Wed, 11 Oct 2017 10:31:22 -0400 Received: (nullmailer pid 28707 invoked by uid 1000); Wed, 11 Oct 2017 14:35:13 -0000 Resent-To: notmuch@notmuchmail.org Resent-From: David Bremner Resent-Date: Wed, 11 Oct 2017 11:35:13 -0300 Resent-Message-ID: <871sm93g7y.fsf@tesseract.cs.unb.ca> Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1d7uhZ-0006nS-O9; Mon, 08 May 2017 22:16:37 -0400 Received: (nullmailer pid 13179 invoked by uid 1000); Tue, 09 May 2017 02:17:24 -0000 From: David Bremner To: notmuch@freelists.org Subject: [PATCH 1/3] cli/show: convert keyword options to booleans Message-Id: <20170509021719.13086-2-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170509021719.13086-1-david@tethera.net> References: <20170509021719.13086-1-david@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Wed, 11 Oct 2017 14:35:17 -0000 X-Original-Date: Mon, 8 May 2017 23:17:17 -0300 X-List-Received-Date: Wed, 11 Oct 2017 14:35:17 -0000 There are two keyword options here that impliment boolean options. It is simpler to use the built-in boolean argument handling, and also more robust against divergence in parsing boolean and keyword arguments. --- notmuch-show.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 7021008e..2f1904db 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1028,8 +1028,8 @@ enum { /* The following is to allow future options to be added more easily */ enum { - EXCLUDE_TRUE, - EXCLUDE_FALSE, + EXCLUDE_FALSE = FALSE, + EXCLUDE_TRUE = TRUE, }; int @@ -1060,15 +1060,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) { "raw", NOTMUCH_FORMAT_RAW }, { 0, 0 } } }, { NOTMUCH_OPT_INT, ¬much_format_version, "format-version", 0, 0 }, - { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', - (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_BOOLEAN, &exclude, "exclude", 'x', 0 }, + { NOTMUCH_OPT_BOOLEAN, &entire_thread, "entire-thread", 't', 0 }, { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, -- 2.11.0