From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 96B1E431FB6 for ; Sat, 26 May 2012 19:33:02 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 KvxIS+UkP-g6 for ; Sat, 26 May 2012 19:33:00 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 669E3431FAF for ; Sat, 26 May 2012 19:33:00 -0700 (PDT) Received: by pbbrr13 with SMTP id rr13so4009919pbb.26 for ; Sat, 26 May 2012 19:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:to:subject:in-reply-to:references:mime-version :content-type:content-disposition:content-transfer-encoding; bh=Q5Md19suo1Z8i6GVONL+GJqDpUlMAXw/Dt7aKmwj1lQ=; b=FOox/St+AugHXGKEid+/yv5QKsIrMnZ/lzbz06Vxz2oEW+QbZ21gPnhNJNOcTGQkMr O/JI7DlD2bYhHeyLGtHkjdSCZjjKdgzwp4CmG4fKw1ObweoPOK2u7LwOQEKWi4g9KlR9 InxCvAT+9ZCRbFJw0VZXVyIYxeONpkZPGUUE1Z+AsmOYMZoJ43eugXqRiidJSvl0aSB8 n0x9IrsD9sY9fLmyOlrBG3h/afrkm1eOOBrKhRItRi7n6ef1B8SqzmWIw+xYl/I4znYK dx9IaOEeNA69BBoxc0Fqy4PhVnbjsBRNmcQPhRc4dcxGbYEFaKthHly5lygmNgzt7QAP dEtA== Received: by 10.68.226.73 with SMTP id rq9mr12743599pbc.145.1338085979578; Sat, 26 May 2012 19:32:59 -0700 (PDT) Received: from localhost (215.42.233.220.static.exetel.com.au. [220.233.42.215]) by mx.google.com with ESMTPS id rj4sm14338466pbc.30.2012.05.26.19.32.56 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 19:32:57 -0700 (PDT) Date: Sun, 27 May 2012 12:32:53 +1000 Message-ID: <20120527123253.GA3049@hili.localdomain> From: Peter Wang To: notmuch@notmuchmail.org Subject: Re: [PATCH v5 1/5] cli: command line parsing: allow default for keyword options In-Reply-To: <1338047694-32548-2-git-send-email-markwalters1009@gmail.com> References: <1338047694-32548-1-git-send-email-markwalters1009@gmail.com> <1338047694-32548-2-git-send-email-markwalters1009@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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, 27 May 2012 02:33:02 -0000 On Sat, 26 May 2012 16:54:50 +0100, Mark Walters wrote: > This changes the parsing for "keyword" options so that if the option > is specified with no argument the first possible argument is > chosen. This make it easier to add options to existing boolean > arguments (the existing --option can default to TRUE). This has the side-effect of allowing defaults for all keyword options, right? I'm not sure that's desirable when the default is non-obvious. Maybe keyword options which allow an optional argument should have an explicit entry in the notmuch_keyword_t[] array, e.g. under "" or "default". > diff --git a/command-line-arguments.c b/command-line-arguments.c > index 76b185f..d40c7e6 100644 > --- a/command-line-arguments.c > +++ b/command-line-arguments.c > @@ -11,10 +11,16 @@ > */ > > static notmuch_bool_t > -_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) { > +_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { > > const notmuch_keyword_t *keywords = arg_desc->keywords; > > + if (next == 0) { > +/* No keyword given so return first option as default */ > + *((int *)arg_desc->output_var) = keywords->value; > + return TRUE; > + } Indentation. Peter