]> git.notmuchmail.org Git - notmuch/blob - test/arg-test.c
python: move Threads class into its own file
[notmuch] / test / arg-test.c
1 #include <stdio.h>
2 #include "command-line-arguments.h"
3
4
5 int main(int argc, char **argv){
6
7     int opt_index=1;
8
9     int kw_val=0;
10     int int_val=0;
11     char *pos_arg1=NULL;
12     char *pos_arg2=NULL;
13     char *string_val=NULL;
14
15     notmuch_opt_desc_t options[] = {
16         { NOTMUCH_OPT_KEYWORD, &kw_val, "keyword", 'k',
17           (notmuch_keyword_t []){ { "one", 1 },
18                                   { "two", 2 },
19                                   { 0, 0 } } },
20         { NOTMUCH_OPT_INT, &int_val, "int", 'i', 0},
21         { NOTMUCH_OPT_STRING, &string_val, "string", 's', 0},
22         { NOTMUCH_OPT_POSITION, &pos_arg1, 0,0, 0},
23         { NOTMUCH_OPT_POSITION, &pos_arg2, 0,0, 0},
24         { 0, 0, 0, 0, 0 } };
25
26     opt_index = parse_arguments(argc, argv, options, 1);
27
28     if (opt_index < 0)
29         return 1;
30
31     if (kw_val)
32         printf("keyword %d\n", kw_val);
33
34     if (int_val)
35         printf("int %d\n", int_val);
36
37     if (string_val)
38         printf("string %s\n", string_val);
39
40     if (pos_arg1)
41         printf("positional arg 1 %s\n", pos_arg1);
42
43     if (pos_arg2)
44         printf("positional arg 2 %s\n", pos_arg1);
45
46
47     for ( ; opt_index < argc ; opt_index ++) {
48         printf("non parsed arg %d = %s\n", opt_index, argv[opt_index]);
49     }
50
51     return 0;
52 }