6 enum notmuch_opt_type {
8 NOTMUCH_OPT_BOOLEAN, /* --verbose */
9 NOTMUCH_OPT_INT, /* --frob=8 */
10 NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
11 NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */
12 NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */
13 NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
17 * Describe one of the possibilities for a keyword option
18 * 'value' will be copied to the output variable
21 typedef struct notmuch_keyword {
27 * Describe one option.
29 * First two parameters are mandatory.
31 * name is mandatory _except_ for positional arguments.
33 * arg_id is currently unused, but could define short arguments.
35 * keywords is a (possibly NULL) pointer to an array of keywords
37 typedef struct notmuch_opt_desc {
38 enum notmuch_opt_type opt_type;
42 const struct notmuch_keyword *keywords;
47 This is the main entry point for command line argument parsing.
49 Parse command line arguments according to structure options,
50 starting at position opt_index.
52 All output of parsed values is via pointers in options.
54 Parsing stops at -- (consumed) or at the (k+1)st argument
55 not starting with -- (a "positional argument") if options contains
56 k positional argument descriptors.
58 Returns the index of first non-parsed argument, or -1 in case of error.
62 parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);
65 * If the argument parsing loop provided by parse_arguments is not
66 * flexible enough, then the user might be interested in the following
67 * routines, but note that the API to parse_option might have to
68 * change. See command-line-arguments.c for descriptions of these
73 parse_option (const char *arg, const notmuch_opt_desc_t* options);
76 parse_position_arg (const char *arg,
77 int position_arg_index,
78 const notmuch_opt_desc_t* options);