--- /dev/null
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 62AAE6DE1603\r
+ for <notmuch@notmuchmail.org>; Sat, 9 Jan 2016 18:52:00 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.313\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.313 tagged_above=-999 required=5 tests=[AWL=0.238,\r
+ RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id PEJxEJAzkTOZ for <notmuch@notmuchmail.org>;\r
+ Sat, 9 Jan 2016 18:51:58 -0800 (PST)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 83F256DE028A\r
+ for <notmuch@notmuchmail.org>; Sat, 9 Jan 2016 18:51:56 -0800 (PST)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1aI66d-0007Di-2G; Sat, 09 Jan 2016 21:51:47 -0500\r
+Received: (nullmailer pid 29656 invoked by uid 1000);\r
+ Sun, 10 Jan 2016 02:51:47 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [WIP patch 7/9] CLI: add print_status_database\r
+Date: Sat, 9 Jan 2016 22:51:39 -0400\r
+Message-Id: <1452394301-29499-8-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.6.4\r
+In-Reply-To: <1452394301-29499-1-git-send-email-david@tethera.net>\r
+References: <1452394301-29499-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 10 Jan 2016 02:52:00 -0000\r
+\r
+This could probably be used at quite a few places in the existing code,\r
+but in the immediate future I plan to use in some new code in\r
+notmuch-dump\r
+---\r
+ notmuch-client.h | 5 +++++\r
+ status.c | 17 +++++++++++++++++\r
+ 2 files changed, 22 insertions(+)\r
+\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 3bd2903..7c9a1ea 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -459,6 +459,11 @@ print_status_query (const char *loc,\r
+ const notmuch_query_t *query,\r
+ notmuch_status_t status);\r
+ \r
++notmuch_status_t\r
++print_status_database (const char *loc,\r
++ const notmuch_database_t *database,\r
++ notmuch_status_t status);\r
++\r
+ #include "command-line-arguments.h"\r
+ \r
+ extern char *notmuch_requested_db_uuid;\r
+diff --git a/status.c b/status.c\r
+index 8fa81cb..45d3fb4 100644\r
+--- a/status.c\r
++++ b/status.c\r
+@@ -19,3 +19,20 @@ print_status_query (const char *loc,\r
+ }\r
+ return status;\r
+ }\r
++\r
++notmuch_status_t\r
++print_status_database (const char *loc,\r
++ const notmuch_database_t *notmuch,\r
++ notmuch_status_t status)\r
++{\r
++ if (status) {\r
++ const char *msg;\r
++\r
++ fprintf (stderr, "%s: %s\n", loc,\r
++ notmuch_status_to_string (status));\r
++ msg = notmuch_database_status_string (notmuch);\r
++ if (msg)\r
++ fputs (msg, stderr);\r
++ }\r
++ return status;\r
++}\r
+-- \r
+2.6.4\r
+\r