--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9F4F4431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 08:13:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id sk0idobAiMYi for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Jul 2012 08:13:12 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id E815F431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 08:13:11 -0700 (PDT)\r
+Received: by weyt57 with SMTP id t57so3271720wey.26\r
+ for <notmuch@notmuchmail.org>; Sat, 07 Jul 2012 08:13:10 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=wcGuI4HoTnkGRYn5J/S1+eE1wgU18tizzkvfe5CI4ZA=;\r
+ b=K5ZjloGRVZEKLA4cPgud+aRJJYdWFW6VW7mYBzL3NTmt2g0Czqub5pyMyHTz9JDYFG\r
+ ed75NYtsznJyfhqnhfFJ+824nAcY+FMisGWEHY9DpUxKUe6ZYWNEMM7//PboJiRDDNTs\r
+ RocR6G5wW/AJcBlQ3g/r90bV4SdNNUY2yiOkBr67NpfxxmIycEhXIRs32pjQHC4hdVQ6\r
+ KHfKVqnPKdryS+P4IdACFZok/EVOraUVt8ua8j6KWNoNFrSWgrhMeJkQ9TUkN7Zl2hR/\r
+ sgefq7nuc17oavy+OrvOB5rpm8olqZ2rX6tYJbI6qu+ZpMRRmRLK9OYcpDs6DVmU2Cz8\r
+ 8cbQ==\r
+Received: by 10.216.216.95 with SMTP id f73mr5164590wep.149.1341673990702;\r
+ Sat, 07 Jul 2012 08:13:10 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223]) by mx.google.com with ESMTPS id\r
+ bc2sm18280270wib.0.2012.07.07.08.13.09 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 07 Jul 2012 08:13:10 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] cli: allow keyword lists in argument parser.\r
+Date: Sat, 7 Jul 2012 16:12:56 +0100\r
+Message-Id: <1341673978-6094-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1341673978-6094-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1341673978-6094-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 07 Jul 2012 15:13:12 -0000\r
+\r
+We allow keyword lists in the argument parser. The parser returns a\r
+bitfield of the arguments present which is the union of the specified\r
+bitfields for each option. Since it is the union the parser could\r
+allow things like\r
+\r
+--output-headers=default,reply-to\r
+\r
+to get the default headers with reply-to added.\r
+---\r
+ command-line-arguments.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++\r
+ command-line-arguments.h | 3 +-\r
+ 2 files changed, 49 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/command-line-arguments.c b/command-line-arguments.c\r
+index b0a0dab..d322f9e 100644\r
+--- a/command-line-arguments.c\r
++++ b/command-line-arguments.c\r
+@@ -37,6 +37,50 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char\r
+ }\r
+ \r
+ static notmuch_bool_t\r
++_process_keyword_list (const notmuch_opt_desc_t *arg_desc, const char *arg_str) {\r
++\r
++ char *key_str, *final;\r
++ unsigned int matched_keys = 0;\r
++ notmuch_bool_t matched;\r
++ const notmuch_keyword_t *keywords;\r
++\r
++ key_str = strdup (arg_str);\r
++\r
++ do {\r
++ keywords = arg_desc->keywords;\r
++ matched = FALSE;\r
++\r
++ final = strrchr (key_str, ',');\r
++\r
++ if (final) {\r
++ *final = '\0';\r
++ final++;\r
++ } else {\r
++ final = key_str;\r
++ }\r
++\r
++ while (keywords->name && !matched) {\r
++ if (strcmp (final, keywords->name) == 0) {\r
++ matched_keys |= keywords->value;\r
++ matched = TRUE;\r
++ }\r
++ keywords++;\r
++ }\r
++ if (!matched) {\r
++ fprintf (stderr, "unknown keyword: \'%s\' in list %s\n", final, arg_str);\r
++ goto DONE;\r
++ }\r
++ } while (final != key_str);\r
++\r
++ if (arg_desc->output_var) {\r
++ *((unsigned int *)arg_desc->output_var) = matched_keys;\r
++ }\r
++DONE:\r
++ free (key_str);\r
++ return matched;\r
++}\r
++\r
++static notmuch_bool_t\r
+ _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {\r
+ \r
+ if (next == 0) {\r
+@@ -121,6 +165,9 @@ parse_option (const char *arg,\r
+ case NOTMUCH_OPT_KEYWORD:\r
+ return _process_keyword_arg (try, next, value);\r
+ break;\r
++ case NOTMUCH_OPT_KEYWORD_LIST:\r
++ return _process_keyword_list (try, value);\r
++ break;\r
+ case NOTMUCH_OPT_BOOLEAN:\r
+ return _process_boolean_arg (try, next, value);\r
+ break;\r
+diff --git a/command-line-arguments.h b/command-line-arguments.h\r
+index de1734a..f2b2275 100644\r
+--- a/command-line-arguments.h\r
++++ b/command-line-arguments.h\r
+@@ -9,7 +9,8 @@ enum notmuch_opt_type {\r
+ NOTMUCH_OPT_INT, /* --frob=8 */\r
+ NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */\r
+ NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */\r
+- NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */\r
++ NOTMUCH_OPT_POSITION, /* notmuch dump pos_arg */\r
++ NOTMUCH_OPT_KEYWORD_LIST /* --output=header,body */\r
+ };\r
+ \r
+ /*\r
+-- \r
+1.7.9.1\r
+\r