Re: [PATCH 3/5] nmbug-status: Add an nmbug-status(5) man page
[notmuch-archives.git] / 28 / 1d7ff45af88e81d94dd09ef1ee53200873afc6
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 7B2DF6DE1640\r
6  for <notmuch@notmuchmail.org>; Sun,  6 Sep 2015 06:58:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.648\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.648 tagged_above=-999 required=5 tests=[AWL=-1.042,\r
12   RCVD_IN_BRBL_LASTEXT=1.644, RCVD_IN_SBL=2.596, RP_MATCHES_RCVD=-0.55]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id yqg3-669NIf3 for <notmuch@notmuchmail.org>;\r
17  Sun,  6 Sep 2015 06:58:42 -0700 (PDT)\r
18 X-Greylist: delayed 2569 seconds by postgrey-1.35 at arlo;\r
19  Sun, 06 Sep 2015 06:58:42 PDT\r
20 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
21  by arlo.cworth.org (Postfix) with ESMTPS id B7E4D6DE1633\r
22  for <notmuch@notmuchmail.org>; Sun,  6 Sep 2015 06:58:42 -0700 (PDT)\r
23 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
24  (envelope-from <bremner@tethera.net>)\r
25  id 1ZYZnT-0002wz-L9; Sun, 06 Sep 2015 10:15:51 -0300\r
26 Received: (nullmailer pid 29725 invoked by uid 1000); Sun, 06 Sep 2015\r
27  13:15:48 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH 1/3] cli: add utility routine to print error status.\r
31 Date: Sun,  6 Sep 2015 10:15:45 -0300\r
32 Message-Id: <1441545347-29549-1-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.5.1\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.18\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 06 Sep 2015 13:58:44 -0000\r
47 \r
48 No attention to formatting here, initially just focus on getting the\r
49 relevant strings out of the library.\r
50 ---\r
51  Makefile.local   |  1 +\r
52  notmuch-client.h |  9 +++++++++\r
53  status.c         | 21 +++++++++++++++++++++\r
54  3 files changed, 31 insertions(+)\r
55  create mode 100644 status.c\r
56 \r
57 diff --git a/Makefile.local b/Makefile.local\r
58 index 61a9c4c..d58cea0 100644\r
59 --- a/Makefile.local\r
60 +++ b/Makefile.local\r
61 @@ -271,6 +271,7 @@ dataclean: distclean\r
62  notmuch_client_srcs =          \\r
63         command-line-arguments.c\\r
64         debugger.c              \\r
65 +       status.c                \\r
66         gmime-filter-reply.c    \\r
67         hooks.c                 \\r
68         notmuch.c               \\r
69 diff --git a/notmuch-client.h b/notmuch-client.h\r
70 index 882aa30..de8a3b1 100644\r
71 --- a/notmuch-client.h\r
72 +++ b/notmuch-client.h\r
73 @@ -449,6 +449,15 @@ notmuch_database_dump (notmuch_database_t *notmuch,\r
74                        dump_format_t output_format,\r
75                        notmuch_bool_t gzip_output);\r
76  \r
77 +/* If status is non-zero (i.e. error) print appropriate\r
78 +   messages to stderr.\r
79 +*/\r
80 +\r
81 +notmuch_status_t\r
82 +print_status_query (const char *loc,\r
83 +                   const notmuch_query_t *query,\r
84 +                   notmuch_status_t status);\r
85 +\r
86  #include "command-line-arguments.h"\r
87  \r
88  extern char *notmuch_requested_db_uuid;\r
89 diff --git a/status.c b/status.c\r
90 new file mode 100644\r
91 index 0000000..8fa81cb\r
92 --- /dev/null\r
93 +++ b/status.c\r
94 @@ -0,0 +1,21 @@\r
95 +#include "notmuch-client.h"\r
96 +\r
97 +notmuch_status_t\r
98 +print_status_query (const char *loc,\r
99 +                   const notmuch_query_t *query,\r
100 +                   notmuch_status_t status)\r
101 +{\r
102 +    if (status) {\r
103 +       const char *msg;\r
104 +       notmuch_database_t *notmuch;\r
105 +\r
106 +       fprintf (stderr, "%s: %s\n", loc,\r
107 +                notmuch_status_to_string (status));\r
108 +\r
109 +       notmuch = notmuch_query_get_database (query);\r
110 +       msg = notmuch_database_status_string (notmuch);\r
111 +       if (msg)\r
112 +           fputs (msg, stderr);\r
113 +    }\r
114 +    return status;\r
115 +}\r
116 -- \r
117 2.5.1\r
118 \r