[PATCH v3 4/8] cli: add print_status_message()
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu May 10 23:57:55 PDT 2018
This function is a parallel to print_status_query() or
print_status_database(). Thanks to David Bremner for the suggestion!
---
notmuch-client.h | 5 +++++
status.c | 20 ++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/notmuch-client.h b/notmuch-client.h
index 0985a7b0..6c84ecc0 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -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,
diff --git a/status.c b/status.c
index 8bc2fe4b..01fd8c99 100644
--- 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,
--
2.17.0
More information about the notmuch
mailing list