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