From: David Bremner Date: Sun, 5 Apr 2015 20:59:34 +0000 (+0900) Subject: [PATCH 4/4] cli: add standard option processing to config and setup X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1cfe2bf98fc201388f55b49c5f805e5312d92792;p=notmuch-archives.git [PATCH 4/4] cli: add standard option processing to config and setup --- diff --git a/5e/f41e05648df589a8f3fb321fbb0574f1ca42c1 b/5e/f41e05648df589a8f3fb321fbb0574f1ca42c1 new file mode 100644 index 000000000..ef7f87c2e --- /dev/null +++ b/5e/f41e05648df589a8f3fb321fbb0574f1ca42c1 @@ -0,0 +1,111 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 8284C6DE1B56 + for ; Sun, 5 Apr 2015 14:34:32 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.619 +X-Spam-Level: +X-Spam-Status: No, score=0.619 tagged_above=-999 required=5 tests=[AWL=0.609, + T_HEADER_FROM_DIFFERENT_DOMAINS=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 MwLFeG-cA7Us for ; + Sun, 5 Apr 2015 14:34:30 -0700 (PDT) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id 674116DE1B51 + for ; Sun, 5 Apr 2015 14:34:30 -0700 (PDT) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1YerfA-0002Re-0Z; Sun, 05 Apr 2015 21:01:00 +0000 +Received: (nullmailer pid 29566 invoked by uid 1000); Sun, 05 Apr 2015 + 21:00:40 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 4/4] cli: add standard option processing to config and setup +Date: Mon, 6 Apr 2015 05:59:34 +0900 +Message-Id: <1428267574-28797-5-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1428267574-28797-1-git-send-email-david@tethera.net> +References: <1428267574-28797-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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, 05 Apr 2015 21:34:32 -0000 + +In particular this fixes a recently encountered bug where the +"--config" argument to "notmuch setup" is silently ignored, which the +unpleasant consequence of overwriting the users config file. +--- + notmuch-config.c | 12 ++++++++++++ + notmuch-setup.c | 12 ++++++++++++ + 2 files changed, 24 insertions(+) + +diff --git a/notmuch-config.c b/notmuch-config.c +index 2d5c297..054dd3b 100644 +--- a/notmuch-config.c ++++ b/notmuch-config.c +@@ -872,6 +872,18 @@ int + notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) + { + int ret; ++ int opt_index; ++ ++ notmuch_opt_desc_t options[] = { ++ { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, ++ { 0, 0, 0, 0, 0 } ++ }; ++ ++ opt_index = parse_arguments (argc, argv, options, 1); ++ if (opt_index < 0) ++ return EXIT_FAILURE; ++ ++ notmuch_process_shared_options (argv[0]); + + argc--; argv++; /* skip subcommand argument */ + +diff --git a/notmuch-setup.c b/notmuch-setup.c +index 36a6171..5fc6e25 100644 +--- a/notmuch-setup.c ++++ b/notmuch-setup.c +@@ -133,6 +133,7 @@ notmuch_setup_command (notmuch_config_t *config, + size_t new_tags_len; + const char **search_exclude_tags; + size_t search_exclude_tags_len; ++ int opt_index; + + #define prompt(format, ...) \ + do { \ +@@ -145,6 +146,17 @@ notmuch_setup_command (notmuch_config_t *config, + chomp_newline (response); \ + } while (0) + ++ notmuch_opt_desc_t options[] = { ++ { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, ++ { 0, 0, 0, 0, 0 } ++ }; ++ ++ opt_index = parse_arguments (argc, argv, options, 1); ++ if (opt_index < 0) ++ return EXIT_FAILURE; ++ ++ notmuch_process_shared_options (argv[0]); ++ + if (notmuch_config_is_new (config)) + welcome_message_pre_setup (); + +-- +2.1.4 +