From: guyzmo Date: Wed, 8 Apr 2015 14:31:47 +0000 (+0200) Subject: Re: argument parsing refactoring round3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=365225ae61841a0ae6d8d178061cdae6ef12a070;p=notmuch-archives.git Re: argument parsing refactoring round3 --- diff --git a/00/7598010cf41d7131dc288a6db625c0fe36d337 b/00/7598010cf41d7131dc288a6db625c0fe36d337 new file mode 100644 index 000000000..5bdf8c173 --- /dev/null +++ b/00/7598010cf41d7131dc288a6db625c0fe36d337 @@ -0,0 +1,97 @@ +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 401726DE1997 + for ; Wed, 8 Apr 2015 07:40:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.27 +X-Spam-Level: +X-Spam-Status: No, score=-0.27 tagged_above=-999 required=5 tests=[AWL=0.280, + RP_MATCHES_RCVD=-0.55] 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 oeFwnJYdtFaY for ; + Wed, 8 Apr 2015 07:40:21 -0700 (PDT) +X-Greylist: delayed 508 seconds by postgrey-1.35 at arlo; + Wed, 08 Apr 2015 07:40:21 PDT +Received: from mail.m0g.net (vilya.m0g.net [195.154.74.47]) + by arlo.cworth.org (Postfix) with ESMTP id 984B46DE198A + for ; Wed, 8 Apr 2015 07:40:21 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by mail.m0g.net (Postfix) with ESMTP id 2A3403E3993; + Wed, 8 Apr 2015 16:31:52 +0200 (CEST) +X-Virus-Scanned: Debian amavisd-new at vilya.m0g.net +Received: from mail.m0g.net ([127.0.0.1]) + by localhost (sd-38500.dedibox.fr [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id IDKlQ1AwUgej; Wed, 8 Apr 2015 16:31:51 +0200 (CEST) +Received: by mail.m0g.net (Postfix, from userid 1000) + id C40033E63D7; Wed, 8 Apr 2015 16:31:50 +0200 (CEST) +Date: Wed, 8 Apr 2015 16:31:47 +0200 +From: guyzmo +To: David Bremner +Subject: Re: argument parsing refactoring round3 +Message-ID: <20150408143147.GD5218@vilya.online.net> +References: <871tjws8w8.fsf@qmul.ac.uk> + <1428435042-16503-1-git-send-email-david@tethera.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <1428435042-16503-1-git-send-email-david@tethera.net> +User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) +Cc: notmuch@notmuchmail.org +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: Wed, 08 Apr 2015 14:40:24 -0000 + +Hi David, + +On Wed, Apr 08, 2015 at 04:30:38AM +0900, David Bremner wrote: +> I think a dealt with all of Mark's comments, even "notmuch help +> --help". +> +> I ended up creating a new function for the places where we want to +> process _only_ the shared options (config, setup, and help) + +I see you patching and repatching notmuch's CLI to improve it, and I was +wondering whether you had considered actually using `docopt` to generate +the CLI parser from the output. + +It's possible to chain docopts to create a CLI UI very much alike the +git command, and it's more easily maintainable, as you're actually +generating the code from the `--help` page instead of the other way +around, making you focus on how you want the user to use the CLI only. + +Here's the link to the C parser generator: + + https://github.com/docopt/docopt.c + +it might not be perfect as is, but it could be worth trying out? I +actually never tried the .c version of docopt. + +I had a more extensive experience with the python version, and since +then I totally dropped argparse. + + https://github.com/docopt/docopt.c + +I even tend to believe that one could create a full CLI using +python+docopt to actually control notmuch using the python notmuch +interface… Even though I'm pretty sure some would yell at me and +want to burn me as an heretic just for suggesting that :-) + +what do you believe? + +-- +Guyzmo