aboutsummaryrefslogtreecommitdiff
path: root/test/arg-test.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 /test/arg-test.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 'test/arg-test.c')
-rw-r--r--test/arg-test.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/arg-test.c b/test/arg-test.c
index 6c49eacd..736686de 100644
--- a/test/arg-test.c
+++ b/test/arg-test.c
@@ -7,6 +7,7 @@ int main(int argc, char **argv){
int opt_index=1;
int kw_val=0;
+ int fl_val=0;
int int_val=0;
char *pos_arg1=NULL;
char *pos_arg2=NULL;
@@ -17,6 +18,11 @@ int main(int argc, char **argv){
(notmuch_keyword_t []){ { "one", 1 },
{ "two", 2 },
{ 0, 0 } } },
+ { NOTMUCH_OPT_KEYWORD_FLAGS, &fl_val, "flag", 'f',
+ (notmuch_keyword_t []){ { "one", 1 << 0},
+ { "two", 1 << 1 },
+ { "three", 1 << 2 },
+ { 0, 0 } } },
{ NOTMUCH_OPT_INT, &int_val, "int", 'i', 0},
{ NOTMUCH_OPT_STRING, &string_val, "string", 's', 0},
{ NOTMUCH_OPT_POSITION, &pos_arg1, 0,0, 0},
@@ -31,6 +37,9 @@ int main(int argc, char **argv){
if (kw_val)
printf("keyword %d\n", kw_val);
+ if (fl_val)
+ printf("flags %d\n", fl_val);
+
if (int_val)
printf("int %d\n", int_val);