]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-count.c
test: make python tests compatible with python3
[notmuch] / notmuch-count.c
index 01e4e3012b8a07c799418c1c256107bb4e1cffa4..57a88a8d1806df1bb0616b64a2555994319f37dd 100644 (file)
@@ -146,14 +146,15 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
                                  { 0, 0 } } },
        { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },
        { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
+       { NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },
        { 0, 0, 0, 0, 0 }
     };
 
     opt_index = parse_arguments (argc, argv, options, 1);
+    if (opt_index < 0)
+       return EXIT_FAILURE;
 
-    if (opt_index < 0) {
-       return 1;
-    }
+    notmuch_process_shared_options (argv[0]);
 
     if (input_file_name) {
        batch = TRUE;
@@ -161,23 +162,23 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
        if (input == NULL) {
            fprintf (stderr, "Error opening %s for reading: %s\n",
                     input_file_name, strerror (errno));
-           return 1;
+           return EXIT_FAILURE;
        }
     }
 
     if (batch && opt_index != argc) {
        fprintf (stderr, "--batch and query string are not compatible\n");
-       return 1;
+       return EXIT_FAILURE;
     }
 
     if (notmuch_database_open (notmuch_config_get_database_path (config),
                               NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch))
-       return 1;
+       return EXIT_FAILURE;
 
     query_str = query_string_from_args (config, argc-opt_index, argv+opt_index);
     if (query_str == NULL) {
        fprintf (stderr, "Out of memory.\n");
-       return 1;
+       return EXIT_FAILURE;
     }
 
     if (exclude == EXCLUDE_TRUE) {
@@ -197,5 +198,5 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])
     if (input != stdin)
        fclose (input);
 
-    return ret;
+    return ret ? EXIT_FAILURE : EXIT_SUCCESS;
 }