cli: add print_status_message()
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 11 May 2018 06:57:55 +0000 (02:57 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 26 May 2018 14:32:14 +0000 (07:32 -0700)
This function is a parallel to print_status_query() or
print_status_database().  Thanks to David Bremner for the suggestion!

notmuch-client.h
status.c

index 0985a7b0a334006904814cfe2e5b2d4127976ec2..6c84ecc01af6cebb5f9df2325c024933e0c36cba 100644 (file)
@@ -481,6 +481,11 @@ print_status_query (const char *loc,
                    const notmuch_query_t *query,
                    notmuch_status_t status);
 
+notmuch_status_t
+print_status_message (const char *loc,
+                     const notmuch_message_t *message,
+                     notmuch_status_t status);
+
 notmuch_status_t
 print_status_database (const char *loc,
                       const notmuch_database_t *database,
index 8bc2fe4b47ecba8af5246f8389f9e62f2e33f88c..01fd8c99b8069030ffde0c026a095cbd701cbdfb 100644 (file)
--- a/status.c
+++ b/status.c
@@ -20,6 +20,26 @@ print_status_query (const char *loc,
     return status;
 }
 
+notmuch_status_t
+print_status_message (const char *loc,
+                     const notmuch_message_t *message,
+                     notmuch_status_t status)
+{
+    if (status) {
+       const char *msg;
+       notmuch_database_t *notmuch;
+
+       fprintf (stderr, "%s: %s\n", loc,
+                notmuch_status_to_string (status));
+
+       notmuch = notmuch_message_get_database (message);
+       msg = notmuch_database_status_string (notmuch);
+       if (msg)
+           fputs (msg, stderr);
+    }
+    return status;
+}
+
 notmuch_status_t
 print_status_database (const char *loc,
                    const notmuch_database_t *notmuch,