CLI: add print_status_database
authorDavid Bremner <david@tethera.net>
Sun, 10 Jan 2016 01:34:21 +0000 (21:34 -0400)
committerDavid Bremner <david@tethera.net>
Wed, 30 Mar 2016 01:59:35 +0000 (22:59 -0300)
This could probably be used at quite a few places in the existing code,
but in the immediate future I plan to use in some new code in
notmuch-dump

notmuch-client.h
status.c

index 18e6c60ba6ceb688f3303308247a4c70dd3c1d2a..b3d0b668bc4d142726881c6eb8e471f181de3583 100644 (file)
@@ -462,6 +462,11 @@ print_status_query (const char *loc,
                    const notmuch_query_t *query,
                    notmuch_status_t status);
 
+notmuch_status_t
+print_status_database (const char *loc,
+                      const notmuch_database_t *database,
+                      notmuch_status_t status);
+
 #include "command-line-arguments.h"
 
 extern char *notmuch_requested_db_uuid;
index 8fa81cbf7a2b85c2bf671c517b9edc212622d8b4..45d3fb4e230e9426a194e045421aaaa6dcba684b 100644 (file)
--- a/status.c
+++ b/status.c
@@ -19,3 +19,20 @@ print_status_query (const char *loc,
     }
     return status;
 }
+
+notmuch_status_t
+print_status_database (const char *loc,
+                   const notmuch_database_t *notmuch,
+                   notmuch_status_t status)
+{
+    if (status) {
+       const char *msg;
+
+       fprintf (stderr, "%s: %s\n", loc,
+                notmuch_status_to_string (status));
+       msg = notmuch_database_status_string (notmuch);
+       if (msg)
+           fputs (msg, stderr);
+    }
+    return status;
+}