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_STRING, /* --file=/tmp/gnarf.txt */
12 NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
16 * Describe one of the possibilities for a keyword option
17 * 'value' will be copied to the output variable
20 typedef struct notmuch_keyword {
26 * Describe one option.
28 * First two parameters are mandatory.
30 * name is mandatory _except_ for positional arguments.
32 * arg_id is currently unused, but could define short arguments.
34 * keywords is a (possibly NULL) pointer to an array of keywords
36 typedef struct notmuch_opt_desc {
37 enum notmuch_opt_type opt_type;
41 const struct notmuch_keyword *keywords;
46 This is the main entry point for command line argument parsing.
48 Parse command line arguments according to structure options,
49 starting at position opt_index.
51 All output of parsed values is via pointers in options.
53 Parsing stops at -- (consumed) or at the (k+1)st argument
54 not starting with -- (a "positional argument") if options contains
55 k positional argument descriptors.
57 Returns the index of first non-parsed argument, or -1 in case of error.
61 parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int opt_index);
64 * If the argument parsing loop provided by parse_arguments is not
65 * flexible enough, then the user might be interested in the following
66 * routines, but note that the API to parse_option might have to
67 * change. See command-line-arguments.c for descriptions of these
72 parse_option (const char *arg, const notmuch_opt_desc_t* options);
75 parse_position_arg (const char *arg,
76 int position_arg_index,
77 const notmuch_opt_desc_t* options);