X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=command-line-arguments.h;h=c0228f7cb634dca5f34182a53e40d0803dc644c5;hp=af8b1cebd626d9fd5d5ce8fb89af063581e81c64;hb=733ccfabca350f65a1d0ba1f64792a8a436da273;hpb=2cf7b27a0c4b4e746e2e40752c55ddb4d54798b2 diff --git a/command-line-arguments.h b/command-line-arguments.h index af8b1ceb..c0228f7c 100644 --- a/command-line-arguments.h +++ b/command-line-arguments.h @@ -1,16 +1,9 @@ #ifndef NOTMUCH_OPTS_H #define NOTMUCH_OPTS_H -#include "notmuch.h" +#include -enum notmuch_opt_type { - NOTMUCH_OPT_END = 0, - NOTMUCH_OPT_BOOLEAN, /* --verbose */ - NOTMUCH_OPT_INT, /* --frob=8 */ - NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */ - NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */ - NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */ -}; +#include "notmuch.h" /* * Describe one of the possibilities for a keyword option @@ -22,23 +15,28 @@ typedef struct notmuch_keyword { int value; } notmuch_keyword_t; -/* - * Describe one option. - * - * First two parameters are mandatory. - * - * name is mandatory _except_ for positional arguments. - * - * arg_id is currently unused, but could define short arguments. - * - * keywords is a (possibly NULL) pointer to an array of keywords - */ +/* Describe one option. */ typedef struct notmuch_opt_desc { - enum notmuch_opt_type opt_type; - void *output_var; + /* One and only one of opt_* must be set. */ + const struct notmuch_opt_desc *opt_inherit; + bool *opt_bool; + int *opt_int; + int *opt_keyword; + int *opt_flags; + const char **opt_string; + const char **opt_position; + + /* Must be set except for opt_inherit and opt_position. */ const char *name; - int arg_id; - struct notmuch_keyword *keywords; + + /* Optional, if non-NULL, set to true if the option is present. */ + bool *present; + + /* Optional, allow empty strings for opt_string. */ + bool allow_empty; + + /* Must be set for opt_keyword and opt_flags. */ + const struct notmuch_keyword *keywords; } notmuch_opt_desc_t; @@ -68,10 +66,10 @@ parse_arguments (int argc, char **argv, const notmuch_opt_desc_t *options, int o * functions. */ -notmuch_bool_t -parse_option (const char *arg, const notmuch_opt_desc_t* options); +int +parse_option (int argc, char **argv, const notmuch_opt_desc_t* options, int opt_index); -notmuch_bool_t +bool parse_position_arg (const char *arg, int position_arg_index, const notmuch_opt_desc_t* options);