From db057a95a1aaf16958080d8d725741e878d48060 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 11 Mar 2012 21:26:07 +0200 Subject: [PATCH] Re: [PATCH 0/3] argument parsing additions --- 39/006db6203338ab5268bdcddce989854469da74 | 161 ++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 39/006db6203338ab5268bdcddce989854469da74 diff --git a/39/006db6203338ab5268bdcddce989854469da74 b/39/006db6203338ab5268bdcddce989854469da74 new file mode 100644 index 000000000..bf0c66e84 --- /dev/null +++ b/39/006db6203338ab5268bdcddce989854469da74 @@ -0,0 +1,161 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BF61C431FAF + for ; Sun, 11 Mar 2012 12:26:19 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 6nUreTTVMYrA for ; + Sun, 11 Mar 2012 12:26:15 -0700 (PDT) +Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com + [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id EDDE3431FAE + for ; Sun, 11 Mar 2012 12:26:14 -0700 (PDT) +Received: by lbok6 with SMTP id k6so1094911lbo.26 + for ; Sun, 11 Mar 2012 12:26:12 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type:x-gm-message-state; + bh=M+ezVKHFb+hK0x36S8SDYFu+W1WGDBgin6zLK2KPWmQ=; + b=Bbyl4+fYEOQLOEOzJ9W4iEYDyreDB260yVPGIe3BMao78tkvFkUv0Hck9SG13Jv7dk + YeQsWwqreP+BS31XLytyzpfhwVVtJ/EThyVH6hE4TjOMY0duJ4C5bzxDixT/GF+3COHe + CZhXqAboSx202MOwP180UZAFIyNUWd9UeKay84zbmkDPh9hfpSrHjN2LmLmjStA28an9 + JREyIPSUzxJe8TyfyfXw8wUdqhC++ER+Ow8OABDeZlVYmSMtgGJW0V6WpLPyD+kaAN/e + ec/gUrdUmdoBx2oT+up7orkPBX2c3mejXxWT/jl7ueh2EOft1rnbxe5CwEzIONdnKp86 + 6ZZQ== +Received: by 10.152.127.9 with SMTP id nc9mr7204136lab.20.1331493971948; + Sun, 11 Mar 2012 12:26:11 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi. + [84.248.80.253]) + by mx.google.com with ESMTPS id nq2sm11631359lab.4.2012.03.11.12.26.09 + (version=SSLv3 cipher=OTHER); Sun, 11 Mar 2012 12:26:10 -0700 (PDT) +From: Jani Nikula +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH 0/3] argument parsing additions +In-Reply-To: <87vcmchf8c.fsf@qmul.ac.uk> +References: <87399iicit.fsf@qmul.ac.uk> + <87vcmchf8c.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.11.1+295~g780f284 (http://notmuchmail.org) Emacs/23.3.1 + (i686-pc-linux-gnu) +Date: Sun, 11 Mar 2012 21:26:07 +0200 +Message-ID: <87ty1vym5s.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Gm-Message-State: + ALoCoQmLHvi+0/Qb2OyX8TyCRguk20Rr4jd7oUWeLzS0F2u+kPS79hJ0MXzDBGTrc7EBKC0+RNbP +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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, 11 Mar 2012 19:26:19 -0000 + +On Sat, 10 Mar 2012 11:23:15 +0000, Mark Walters wrote: +> On Sat, 10 Mar 2012 00:33:27 +0200, Jani Nikula wrote: +> > Hi Mark - +> > +> > I'm not sure which is worse, criticizing or rewriting other people's +> > patches. I already did the former, and now I'm doing the +> > latter. Apologies for both. I didn't really mean to write these patches, +> > but it turned out to be more fun writing a proper reply in C than in +> > English. +> > +> > Patch 1 adds --arg=true and --arg=false support for booleans. It's not +> > strictly required for the --entire-thread support in patch 3, which uses +> > the extension of keyword arguments from patch 2, but it's for +> > consistency across boolean arguments. +> +> Hi +> +> I like patch 1: I have an almost identical to my version (in the series +> I just sent to the list +> id:"1331377533-30262-1-git-send-email-markwalters1009@gmail.com> +> X-Mailer: git-send-email 1.7.9.1"). + +id:"1331377533-30262-1-git-send-email-markwalters1009@gmail.com" (fixed +reference) + +Either of the patches should be pushed forward. The command line +interface is sound, in line with notmuch style, and allows boolean +parameters defaulting to true that you can switch off. And it needs no +changes to argument parser users. + +> I am not sure about patch 2 and patch 3. Do you have a use case for +> --option except when option is a boolean? + +For the sake of example, if some command produced some unformatted +output by default, you could enable some formatting with --format and +specify details with --format=foo or --format=bar. But admittedly it's a +bit contrived. + +And using that for the bool case is also abusing it. + +> Otherwise I think I prefer either my +> approach (abusing a notmuch_bool_t) or just adding an option +> NOTMUCH_OPT_BOOLEAN_AS_INT which does boolean parsing but returns an +> int. I guess I am saying that I think allowing boolean options which can +> sometimes default to true and sometimes to false is more useful than +> allowing --option for arbitrary keywords (*). +> +> What do you think? + +I think we're somewhere between overengineering and bikeshedding, and we +should just fix the issue at hand with the "boolean" -1 value hack. Your +v2 series accomplishes what's needed. Let's go with it, and consider a +more general approach if another case comes up. (I actually wrote +patches to add generic support for getting info about which arguments +were set in the command line, but I think it's more trouble than its +worth.) + + +BR, +Jani. + + +> +> Best wishes +> +> Mark +> +> (*) Indeed, I was thinking of the former as a possibility for the +> exclude code, but I am erring towards just using keywords so I can allow +> more options as you suggested. +> +> +> > +> > Please let me know what you think. +> > +> > BR, +> > Jani. +> > +> > +> > Jani Nikula (3): +> > command-line-arguments: allow true and false keywords for booleans +> > command-line-arguments: support keyword arguments with default value +> > cli: allow switching off entire thread mode in notmuch show json +> > format +> > +> > command-line-arguments.c | 45 +++++++++++++++++++++++++++++++++++++++------ +> > command-line-arguments.h | 1 + +> > notmuch-show.c | 12 ++++++++++-- +> > 3 files changed, 50 insertions(+), 8 deletions(-) +> > +> > -- +> > 1.7.5.4 +> > -- 2.26.2