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 13A18431FCB for ; Sun, 18 Aug 2013 04:25:29 -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 9o8F7SyBfnQd for ; Sun, 18 Aug 2013 04:25:19 -0700 (PDT) Received: from mail-bk0-f42.google.com (mail-bk0-f42.google.com [209.85.214.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 84784431FBC for ; Sun, 18 Aug 2013 04:25:19 -0700 (PDT) Received: by mail-bk0-f42.google.com with SMTP id my10so1152231bkb.29 for ; Sun, 18 Aug 2013 04:25:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=US38LWj78PjN37Zd1UVmXpkSAIzaXlWFaOWGWbCPZ0Q=; b=Yy54RzY3D55keEVf37KlEWJVJLd2L5kTdjyFiw4Hvjlk9C4ct60B2cxTj8VO7C6HiC 3X7cBPeMb1WUkz4u1C4AFyaFrYi3QGNwNHQUzGg+YxZA82q16LKp+C3IPXU88l2/2yrL RjRAhsJRV159OLpxKROIuHk3/+8SaHT3faCx+LpLD/+NseIGlznkTDIv01zvKPVBsbb+ SPKka/K5bHtAC4RyyT7Bm9710qU9Hje3EPpOmrvoMUBRjvpLDWzSkIQiFMnGzxqNeA3q Vmi7oUyImaCki68aImHFs1FGGK9VIGZTOinyDVhQvZjkZhMJ3E8Am1L2MkbQFthlmLNZ JuTA== X-Gm-Message-State: ALoCoQlbZWfSB07afBb4efVY5MD6HXtEqtF+gX3pVYFzB0UTxTIkEt78Bm4jZWcm+y2LQa931fHA X-Received: by 10.204.173.196 with SMTP id q4mr4293544bkz.9.1376825115571; Sun, 18 Aug 2013 04:25:15 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id h7sm636208bki.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 18 Aug 2013 04:25:14 -0700 (PDT) From: Jani Nikula To: John Lenz , Tomi Ollila , notmuch@notmuchmail.org Subject: Re: cli: add --include-html option to notmuch show In-Reply-To: References: User-Agent: Notmuch/0.15.2+227~g40b2846 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Sun, 18 Aug 2013 14:25:16 +0300 Message-ID: <87k3jjutpf.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain 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, 18 Aug 2013 11:25:29 -0000 On Sat, 17 Aug 2013, John Lenz wrote: > On Sun Aug 4 14:47 -0500 2013, Tomi Ollila wrote: >> The next question is should we have new option as >> >> --include-html >> >> or as >> >> --include-html=(true|false) >> >> or even >> >> --body=(true|false|text-and-html) >> >> See --exclude option in http://notmuchmail.org/manpages/notmuch-search-1/ >> and --body option in http://notmuchmail.org/manpages/notmuch-show-1/ >> for comparison... >> > > I have no preference here, although I guess I would vote for > --include-html=(true|false) since adding it to --body makes the --body > options confusing: to make sense the body options should be > --body=(text|text-and-html|none) but of course you can't change that and > break the command line API. Well, maybe you could add all three > --body=(text|text-and-html|none) and still accept true/false for > compatibility. Hi John & Tomi - We could trivially amend the argument parser to |= the keyword values (instead of =) to allow specifying keywords arguments multiple times on the command line. With the keyword values specified as bit flags, we could then have 'notmuch show --body=text --body=html ...' return both text and html, and allow trivial future extension too. --body=true and --body=false could be handled specially for backwards compatibility, for example by forcing text only or no parts, respectively. Since the default is currently text, --body=none might be a suitable synonym for --body=false, while the boolean alternatives could be deprecated. A little less trivially it's also possible to support e.g. comma separated keyword values, such as --body=text,html but I do prefer the (implementation) simplicity of the above. Untested patch to the argument parser below. Cheers, Jani. diff --git a/command-line-arguments.c b/command-line-arguments.c index bf9aeca..c426054 100644 --- a/command-line-arguments.c +++ b/command-line-arguments.c @@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char while (keywords->name) { if (strcmp (arg_str, keywords->name) == 0) { if (arg_desc->output_var) { - *((int *)arg_desc->output_var) = keywords->value; + if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS) + *((int *)arg_desc->output_var) |= keywords->value; + else + *((int *)arg_desc->output_var) = keywords->value; } return TRUE; } @@ -146,6 +149,7 @@ parse_option (const char *arg, switch (try->opt_type) { case NOTMUCH_OPT_KEYWORD: + case NOTMUCH_OPT_KEYWORD_FLAGS: return _process_keyword_arg (try, next, value); break; case NOTMUCH_OPT_BOOLEAN: diff --git a/command-line-arguments.h b/command-line-arguments.h index de1734a..085a492 100644 --- a/command-line-arguments.h +++ b/command-line-arguments.h @@ -8,6 +8,7 @@ enum notmuch_opt_type { NOTMUCH_OPT_BOOLEAN, /* --verbose */ NOTMUCH_OPT_INT, /* --frob=8 */ NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */ + NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */ NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */ NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */ };