1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 9F4F4431FB6
\r
6 for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 08:13:12 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id sk0idobAiMYi for <notmuch@notmuchmail.org>;
\r
18 Sat, 7 Jul 2012 08:13:12 -0700 (PDT)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id E815F431FAF
\r
23 for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 08:13:11 -0700 (PDT)
\r
24 Received: by weyt57 with SMTP id t57so3271720wey.26
\r
25 for <notmuch@notmuchmail.org>; Sat, 07 Jul 2012 08:13:10 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=wcGuI4HoTnkGRYn5J/S1+eE1wgU18tizzkvfe5CI4ZA=;
\r
29 b=K5ZjloGRVZEKLA4cPgud+aRJJYdWFW6VW7mYBzL3NTmt2g0Czqub5pyMyHTz9JDYFG
\r
30 ed75NYtsznJyfhqnhfFJ+824nAcY+FMisGWEHY9DpUxKUe6ZYWNEMM7//PboJiRDDNTs
\r
31 RocR6G5wW/AJcBlQ3g/r90bV4SdNNUY2yiOkBr67NpfxxmIycEhXIRs32pjQHC4hdVQ6
\r
32 KHfKVqnPKdryS+P4IdACFZok/EVOraUVt8ua8j6KWNoNFrSWgrhMeJkQ9TUkN7Zl2hR/
\r
33 sgefq7nuc17oavy+OrvOB5rpm8olqZ2rX6tYJbI6qu+ZpMRRmRLK9OYcpDs6DVmU2Cz8
\r
35 Received: by 10.216.216.95 with SMTP id f73mr5164590wep.149.1341673990702;
\r
36 Sat, 07 Jul 2012 08:13:10 -0700 (PDT)
\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.
\r
38 [94.192.233.223]) by mx.google.com with ESMTPS id
\r
39 bc2sm18280270wib.0.2012.07.07.08.13.09 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 07 Jul 2012 08:13:10 -0700 (PDT)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 1/3] cli: allow keyword lists in argument parser.
\r
44 Date: Sat, 7 Jul 2012 16:12:56 +0100
\r
45 Message-Id: <1341673978-6094-2-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1341673978-6094-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1341673978-6094-1-git-send-email-markwalters1009@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sat, 07 Jul 2012 15:13:12 -0000
\r
63 We allow keyword lists in the argument parser. The parser returns a
\r
64 bitfield of the arguments present which is the union of the specified
\r
65 bitfields for each option. Since it is the union the parser could
\r
68 --output-headers=default,reply-to
\r
70 to get the default headers with reply-to added.
\r
72 command-line-arguments.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
\r
73 command-line-arguments.h | 3 +-
\r
74 2 files changed, 49 insertions(+), 1 deletions(-)
\r
76 diff --git a/command-line-arguments.c b/command-line-arguments.c
\r
77 index b0a0dab..d322f9e 100644
\r
78 --- a/command-line-arguments.c
\r
79 +++ b/command-line-arguments.c
\r
80 @@ -37,6 +37,50 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
\r
83 static notmuch_bool_t
\r
84 +_process_keyword_list (const notmuch_opt_desc_t *arg_desc, const char *arg_str) {
\r
86 + char *key_str, *final;
\r
87 + unsigned int matched_keys = 0;
\r
88 + notmuch_bool_t matched;
\r
89 + const notmuch_keyword_t *keywords;
\r
91 + key_str = strdup (arg_str);
\r
94 + keywords = arg_desc->keywords;
\r
97 + final = strrchr (key_str, ',');
\r
106 + while (keywords->name && !matched) {
\r
107 + if (strcmp (final, keywords->name) == 0) {
\r
108 + matched_keys |= keywords->value;
\r
114 + fprintf (stderr, "unknown keyword: \'%s\' in list %s\n", final, arg_str);
\r
117 + } while (final != key_str);
\r
119 + if (arg_desc->output_var) {
\r
120 + *((unsigned int *)arg_desc->output_var) = matched_keys;
\r
127 +static notmuch_bool_t
\r
128 _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
\r
131 @@ -121,6 +165,9 @@ parse_option (const char *arg,
\r
132 case NOTMUCH_OPT_KEYWORD:
\r
133 return _process_keyword_arg (try, next, value);
\r
135 + case NOTMUCH_OPT_KEYWORD_LIST:
\r
136 + return _process_keyword_list (try, value);
\r
138 case NOTMUCH_OPT_BOOLEAN:
\r
139 return _process_boolean_arg (try, next, value);
\r
141 diff --git a/command-line-arguments.h b/command-line-arguments.h
\r
142 index de1734a..f2b2275 100644
\r
143 --- a/command-line-arguments.h
\r
144 +++ b/command-line-arguments.h
\r
145 @@ -9,7 +9,8 @@ enum notmuch_opt_type {
\r
146 NOTMUCH_OPT_INT, /* --frob=8 */
\r
147 NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
\r
148 NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */
\r
149 - NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
\r
150 + NOTMUCH_OPT_POSITION, /* notmuch dump pos_arg */
\r
151 + NOTMUCH_OPT_KEYWORD_LIST /* --output=header,body */
\r