From: Mark Walters Date: Tue, 7 Apr 2015 07:19:19 +0000 (+0100) Subject: Re: argument parsing refactoring, round 2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=adc86b01e4327c204f7b669ef39a66fee96b220f;p=notmuch-archives.git Re: argument parsing refactoring, round 2 --- diff --git a/93/f87cabca63b6516f8e19503d1f1bbbbb3d1efc b/93/f87cabca63b6516f8e19503d1f1bbbbb3d1efc new file mode 100644 index 000000000..549247853 --- /dev/null +++ b/93/f87cabca63b6516f8e19503d1f1bbbbb3d1efc @@ -0,0 +1,162 @@ +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 BDCC46DE1978 + for ; Tue, 7 Apr 2015 00:19:37 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.268 +X-Spam-Level: +X-Spam-Status: No, score=0.268 tagged_above=-999 required=5 tests=[AWL=1.916, + DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + 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 xX9nkKyIzjhd for ; + Tue, 7 Apr 2015 00:19:35 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + by arlo.cworth.org (Postfix) with ESMTPS id 04A036DE1974 + for ; Tue, 7 Apr 2015 00:19:34 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1YfNnC-0004o2-Kq; Tue, 07 Apr 2015 08:19:29 +0100 +Received: from 188.29.19.158.threembb.co.uk ([188.29.19.158] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1YfNnB-00065R-GX; Tue, 07 Apr 2015 08:19:26 +0100 +From: Mark Walters +To: David Bremner , David Bremner , + notmuch@notmuchmail.org +Subject: Re: argument parsing refactoring, round 2 +In-Reply-To: <1428322958-2887-1-git-send-email-david@tethera.net> +References: <87d23ixnr7.fsf@maritornes.cs.unb.ca> + <1428322958-2887-1-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 07 Apr 2015 08:19:19 +0100 +Message-ID: <871tjws8w8.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-QM-SPAM-Info: 188.29.19.158 is in Janet mirror of Spamhaus XBL; + see http://www.spamhaus.org/xbl/ +X-Sender-Host-Address: 188.29.19.158 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 9e5abac1c37783f5f6ec2574cb490661 (of first 20000 bytes) +X-SpamAssassin-Score: -0.0 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.0 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider + * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain +X-QM-Scan-Virus: ClamAV says the message is clean +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: Tue, 07 Apr 2015 07:19:37 -0000 + + +On Mon, 06 Apr 2015, David Bremner wrote: +> Thanks to Mark for pointing out on IRC that the previous version had problems linking the test suite helpers. That's fixed here by adding a couple stubs. +> +> Here's the diff, roughly with the previous version (actually the first +> hunk is with a slightly later version, where I fixed one bug and +> introduced another). + +Hi + +I like the shared options and the series in general. I have some very +minor nits: + +The first is that I think you missed the second command in +notmuch-search.c: i.e., notmuch_address_command so that doesn't respect +these options. (You could either just add it there or to common_options +if you prefer) + +The second is utterly trivial: is it worth having the shared options for +help too? At the moment notmuch help --help just says "sorry --help is +not a command". + +The other (very minor things) I will send in replies to the individual +patches. + +Best wishes + +Mark + + +> +> diff --git a/notmuch-config.c b/notmuch-config.c +> index 568b3dc..f2cd6a8 100644 +> --- a/notmuch-config.c +> +++ b/notmuch-config.c +> @@ -885,9 +885,9 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[]) +> +> notmuch_process_shared_options (argv[0]); +> +> - /* skip subcommand argument */ +> - argc-= opt_index+1; +> - argv+= opt_index+1; +> + /* skip at least subcommand argument */ +> + argc-= opt_index; +> + argv+= opt_index; +> +> if (argc < 1) { +> fprintf (stderr, "Error: notmuch config requires at least one argument.\n"); +> diff --git a/notmuch-setup.c b/notmuch-setup.c +> index 5fc6e25..6a020dc 100644 +> --- a/notmuch-setup.c +> +++ b/notmuch-setup.c +> @@ -155,7 +155,7 @@ notmuch_setup_command (notmuch_config_t *config, +> if (opt_index < 0) +> return EXIT_FAILURE; +> +> - notmuch_process_shared_options (argv[0]); +> + notmuch_process_shared_options ("setup"); +> +> if (notmuch_config_is_new (config)) +> welcome_message_pre_setup (); +> diff --git a/test/random-corpus.c b/test/random-corpus.c +> index 790193d..6c467bb 100644 +> --- a/test/random-corpus.c +> +++ b/test/random-corpus.c +> @@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count) +> return buf; +> } +> +> +/* stubs since we cannot link with notmuch.o */ +> +const notmuch_opt_desc_t notmuch_shared_options[] = { +> + { 0, 0, 0, 0, 0 } +> +}; +> + +> +void +> +notmuch_process_shared_options (unused (const char *dummy)) +> +{ +> +} +> +> int +> main (int argc, char **argv) +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch