]> git.notmuchmail.org Git - notmuch/blobdiff - test/arg-test.c
cli: Add support for parsing keyword-flag arguments
[notmuch] / test / arg-test.c
index 6c49eacd7f3a9bab7537ee82059b6c66a5a76d7a..736686ded2c07287f1daf237a5b6c22f71e5bb82 100644 (file)
@@ -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);