cli: refactor boolean argument processing

Clean up the control flow to prepare for future changes. No functional
changes.
This commit is contained in:
Jani Nikula 2017-10-01 23:53:19 +03:00 committed by David Bremner
parent 9a0df8128c
commit e704947855

View file

@ -39,21 +39,20 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
static notmuch_bool_t static notmuch_bool_t
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) { _process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
notmuch_bool_t value;
if (next == '\0') { if (next == '\0' || strcmp (arg_str, "true") == 0) {
*arg_desc->opt_bool = TRUE; value = TRUE;
return 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;
} }
if (strcmp (arg_str, "false") == 0) {
*arg_desc->opt_bool = FALSE; *arg_desc->opt_bool = value;
return TRUE;
} return TRUE;
if (strcmp (arg_str, "true") == 0) {
*arg_desc->opt_bool = TRUE;
return TRUE;
}
fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
return FALSE;
} }
static notmuch_bool_t static notmuch_bool_t