summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2017-10-01 23:53:19 +0300
committerDavid Bremner <david@tethera.net>2017-10-04 22:03:10 -0300
commite70494785541c32989b5c31360e1d9ac57e106ee (patch)
treecc922b3d719a27a19a353e32b57a13577040ae6c
parent9a0df8128c1a2f92d03035aebbd7a90eb93ec601 (diff)
cli: refactor boolean argument processing
Clean up the control flow to prepare for future changes. No functional changes.
-rw-r--r--command-line-arguments.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/command-line-arguments.c b/command-line-arguments.c
index 39940d5f..ee8be189 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -39,21 +39,20 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
static notmuch_bool_t
_process_boolean_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
-
- if (next == '\0') {
- *arg_desc->opt_bool = TRUE;
- return TRUE;
- }
- if (strcmp (arg_str, "false") == 0) {
- *arg_desc->opt_bool = FALSE;
- return TRUE;
- }
- if (strcmp (arg_str, "true") == 0) {
- *arg_desc->opt_bool = TRUE;
- return TRUE;
+ notmuch_bool_t 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;
}
- fprintf (stderr, "Unknown argument \"%s\" for (boolean) option \"%s\".\n", arg_str, arg_desc->name);
- return FALSE;
+
+ *arg_desc->opt_bool = value;
+
+ return TRUE;
}
static notmuch_bool_t