]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-setup.c
cli: add standard option processing to config, help and setup
[notmuch] / notmuch-setup.c
index 475248b1f9735b2e10f00f013deffa0baac85e7a..7dd5822a9365c0490b9860532de03c1c4c18251c 100644 (file)
@@ -140,11 +140,14 @@ notmuch_setup_command (notmuch_config_t *config,
        fflush (stdout);                                        \
        if (getline (&response, &response_size, stdin) < 0) {   \
            printf ("Exiting.\n");                              \
-           exit (1);                                           \
+           exit (EXIT_FAILURE);                                \
        }                                                       \
        chomp_newline (response);                               \
     } while (0)
 
+    if (notmuch_minimal_options ("setup", argc, argv) < 0)
+       return EXIT_FAILURE;
+
     if (notmuch_config_is_new (config))
        welcome_message_pre_setup ();
 
@@ -223,12 +226,11 @@ notmuch_setup_command (notmuch_config_t *config,
        g_ptr_array_free (tags, TRUE);
     }
 
+    if (notmuch_config_save (config))
+       return EXIT_FAILURE;
 
-    if (! notmuch_config_save (config)) {
-       if (notmuch_config_is_new (config))
-         welcome_message_post_setup ();
-       return 0;
-    } else {
-       return 1;
-    }
+    if (notmuch_config_is_new (config))
+       welcome_message_post_setup ();
+
+    return EXIT_SUCCESS;
 }