aboutsummaryrefslogtreecommitdiff
path: root/command-line-arguments.c
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2014-10-31 22:53:56 +0100
committerDavid Bremner <david@tethera.net>2014-11-01 08:02:21 +0100
commitecc4a9a6441a3b7011d9afb2ca67e9d4ea1fca48 (patch)
tree3c8f3ee740b6f3d418c0c3d781bfb3eac4904b1c /command-line-arguments.c
parentdc398119482b58be5f46cf636127794a002b36e6 (diff)
cli: Add support for parsing keyword-flag arguments
This allows having multiple --foo=bar --foo=baz options on the command line, with the corresponding values OR'd together. [Test added by Michal Sojka]
Diffstat (limited to 'command-line-arguments.c')
-rw-r--r--command-line-arguments.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/command-line-arguments.c b/command-line-arguments.c
index 844d6c3d..c6f72696 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;
}
@@ -152,6 +155,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);
case NOTMUCH_OPT_BOOLEAN:
return _process_boolean_arg (try, next, value);