+ for (keywords = arg_desc->keywords; keywords->name; keywords++) {
+ if (strcmp (arg_str, keywords->name) != 0)
+ continue;
+
+ if (arg_desc->opt_flags && negate)
+ *arg_desc->opt_flags &= ~keywords->value;
+ else if (arg_desc->opt_flags)
+ *arg_desc->opt_flags |= keywords->value;
+ else
+ *arg_desc->opt_keyword = keywords->value;
+
+ return true;
+ }
+ if (next != '\0')
+ fprintf (stderr, "Unknown keyword argument \"%s\" for option \"%s\".\n", arg_str, arg_desc->name);
+ else
+ fprintf (stderr, "Option \"%s\" needs a keyword argument.\n", arg_desc->name);
+ return false;
+}
+
+static bool
+_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next,
+ const char *arg_str, bool negate)
+{
+ bool value;
+
+ if (next == '\0' || strcmp (arg_str, "true") == 0) {
+ value = true;
+ } else if (strcmp (arg_str, "false") == 0) {
+ value = false;
+ } else {
+ fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
+ return false;
+ }
+
+ *arg_desc->opt_bool = negate ? !value : value;
+
+ return true;
+}
+
+static bool
+_process_int_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
+
+ char *endptr;
+ if (next == '\0' || arg_str[0] == '\0') {
+ fprintf (stderr, "Option \"%s\" needs an integer argument.\n", arg_desc->name);
+ return false;
+ }
+
+ *arg_desc->opt_int = strtol (arg_str, &endptr, 10);
+ if (*endptr == '\0')
+ return true;
+
+ fprintf (stderr, "Unable to parse argument \"%s\" for option \"%s\" as an integer.\n",
+ arg_str, arg_desc->name);
+ return false;
+}
+
+static bool
+_process_string_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
+
+ if (next == '\0') {
+ fprintf (stderr, "Option \"%s\" needs a string argument.\n", arg_desc->name);
+ return false;