Re: [Patch v2 4/4] cli: add standard option processing to config and setup
authorMark Walters <markwalters1009@gmail.com>
Tue, 7 Apr 2015 07:24:43 +0000 (08:24 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:45 +0000 (14:48 -0700)
60/cad34d40879a162459ffe6576a9533c9971186 [new file with mode: 0644]

diff --git a/60/cad34d40879a162459ffe6576a9533c9971186 b/60/cad34d40879a162459ffe6576a9533c9971186
new file mode 100644 (file)
index 0000000..66b7ca2
--- /dev/null
@@ -0,0 +1,188 @@
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 5EE036DE1983\r
+ for <notmuch@notmuchmail.org>; Tue,  7 Apr 2015 00:24:57 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.688\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.688 tagged_above=-999 required=5\r
+ tests=[AWL=-0.040, DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\r
+ RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01,\r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id WTTvKfUFniH4 for <notmuch@notmuchmail.org>;\r
+ Tue,  7 Apr 2015 00:24:55 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id D84D46DE1974\r
+ for <notmuch@notmuchmail.org>; Tue,  7 Apr 2015 00:24:54 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1YfNsR-000616-L0; Tue, 07 Apr 2015 08:24:52 +0100\r
+Received: from 188.29.19.158.threembb.co.uk ([188.29.19.158] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1YfNsQ-00070m-5z; Tue, 07 Apr 2015 08:24:51 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: David Bremner <david@tethera.net>, David Bremner <david@tethera.net>,\r
+ notmuch@notmuchmail.org\r
+Subject: Re: [Patch v2 4/4] cli: add standard option processing to config and\r
+ setup\r
+In-Reply-To: <1428322958-2887-5-git-send-email-david@tethera.net>\r
+References: <87d23ixnr7.fsf@maritornes.cs.unb.ca>\r
+ <1428322958-2887-1-git-send-email-david@tethera.net>\r
+ <1428322958-2887-5-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 07 Apr 2015 08:24:43 +0100\r
+Message-ID: <87vbh8qu2s.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-QM-SPAM-Info: 188.29.19.158 is in Janet mirror of Spamhaus XBL;\r
+ see http://www.spamhaus.org/xbl/\r
+X-Sender-Host-Address: 188.29.19.158\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: 60c409073c636466411aa8b2036c8bf0 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -0.1\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -0.1 points.\r
+ Summary of the scoring: \r
+ *  0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider\r
+ *      (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ *      domain\r
+ * -0.1 AWL AWL: Adjusted score from AWL reputation of From: address\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Tue, 07 Apr 2015 07:24:57 -0000\r
+\r
+\r
+Hi\r
+\r
+On Mon, 06 Apr 2015, David Bremner <david@tethera.net> wrote:\r
+> In particular this fixes a recently encountered bug where the\r
+> "--config" argument to "notmuch setup" is silently ignored, which the\r
+> unpleasant consequence of overwriting the users config file.\r
+> ---\r
+>  notmuch-config.c     | 16 +++++++++++++++-\r
+>  notmuch-setup.c      | 12 ++++++++++++\r
+>  test/random-corpus.c |  9 +++++++++\r
+>  3 files changed, 36 insertions(+), 1 deletion(-)\r
+>\r
+> diff --git a/notmuch-config.c b/notmuch-config.c\r
+> index 2d5c297..f2cd6a8 100644\r
+> --- a/notmuch-config.c\r
+> +++ b/notmuch-config.c\r
+> @@ -872,8 +872,22 @@ int\r
+>  notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])\r
+>  {\r
+>      int ret;\r
+> +    int opt_index;\r
+>  \r
+> -    argc--; argv++; /* skip subcommand argument */\r
+> +    notmuch_opt_desc_t options[] = {\r
+> +    { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
+> +    { 0, 0, 0, 0, 0 }\r
+> +    };\r
+> +\r
+> +    opt_index = parse_arguments (argc, argv, options, 1);\r
+> +    if (opt_index < 0)\r
+> +    return EXIT_FAILURE;\r
+> +\r
+> +    notmuch_process_shared_options (argv[0]);\r
+> +\r
+> +    /* skip at least subcommand argument */\r
+> +    argc-= opt_index;\r
+> +    argv+= opt_index;\r
+>  \r
+>      if (argc < 1) {\r
+>      fprintf (stderr, "Error: notmuch config requires at least one argument.\n");\r
+> diff --git a/notmuch-setup.c b/notmuch-setup.c\r
+> index 36a6171..6a020dc 100644\r
+> --- a/notmuch-setup.c\r
+> +++ b/notmuch-setup.c\r
+> @@ -133,6 +133,7 @@ notmuch_setup_command (notmuch_config_t *config,\r
+>      size_t new_tags_len;\r
+>      const char **search_exclude_tags;\r
+>      size_t search_exclude_tags_len;\r
+> +    int opt_index;\r
+>  \r
+>  #define prompt(format, ...)                                 \\r
+>      do {                                                    \\r
+> @@ -145,6 +146,17 @@ notmuch_setup_command (notmuch_config_t *config,\r
+>      chomp_newline (response);                               \\r
+>      } while (0)\r
+>  \r
+> +    notmuch_opt_desc_t options[] = {\r
+> +    { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },\r
+> +    { 0, 0, 0, 0, 0 }\r
+> +    };\r
+> +\r
+> +    opt_index = parse_arguments (argc, argv, options, 1);\r
+> +    if (opt_index < 0)\r
+> +    return EXIT_FAILURE;\r
+> +\r
+> +    notmuch_process_shared_options ("setup");\r
+\r
+Why "setup" here rather than argv[0] or similar? It seems inconsistent\r
+with the other cases.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+> +\r
+>      if (notmuch_config_is_new (config))\r
+>      welcome_message_pre_setup ();\r
+>  \r
+> diff --git a/test/random-corpus.c b/test/random-corpus.c\r
+> index 790193d..6c467bb 100644\r
+> --- a/test/random-corpus.c\r
+> +++ b/test/random-corpus.c\r
+> @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count)\r
+>      return buf;\r
+>  }\r
+>  \r
+> +/* stubs since we cannot link with notmuch.o */\r
+> +const notmuch_opt_desc_t notmuch_shared_options[] = {\r
+> +    { 0, 0, 0, 0, 0 }\r
+> +};\r
+> +\r
+> +void\r
+> +notmuch_process_shared_options (unused (const char *dummy))\r
+> +{\r
+> +}\r
+>  \r
+>  int\r
+>  main (int argc, char **argv)\r
+> -- \r
+> 2.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r