[PATCH v2 12/13] show: Convert do_show to use sprinter
[notmuch-archives.git] / 04 / 5b042666b390c4853c1408aef670872eb81fa1
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 olra.theworths.org (Postfix) with ESMTP id 8FDB7431FD0\r
6         for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 05:12:32 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 1C8fH89r5P03 for <notmuch@notmuchmail.org>;\r
16         Thu, 29 Dec 2011 05:12:30 -0800 (PST)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 5DC6C431FB6\r
21         for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 05:12:30 -0800 (PST)\r
22 Received: from zancas.localnet\r
23         (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
24         [156.34.79.193]) (authenticated bits=0)\r
25         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pBTDCNBv020838\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Thu, 29 Dec 2011 09:12:26 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.77)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RgFmQ-0008Ad-GL; Thu, 29 Dec 2011 09:12:22 -0400\r
31 From: David Bremner <david@tethera.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v3] notmuch: replace built-in help with exec of man\r
34 Date: Thu, 29 Dec 2011 09:11:16 -0400\r
35 Message-Id: <1325164276-31378-1-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.7.3\r
37 In-Reply-To: <20111229022419.GI30150@mit.edu>\r
38 References: <20111229022419.GI30150@mit.edu>\r
39 Cc: David Bremner <bremner@debian.org>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Thu, 29 Dec 2011 13:12:32 -0000\r
53 \r
54 From: David Bremner <bremner@debian.org>\r
55 \r
56 Since we lose the fancy scanning of the commands for which ones take\r
57 search terms, the search terms page SYNOPSIS should be updated.\r
58 ---\r
59  notmuch.c |  482 +++++--------------------------------------------------------\r
60  1 files changed, 35 insertions(+), 447 deletions(-)\r
61 \r
62 diff --git a/notmuch.c b/notmuch.c\r
63 index c0ce026..477a09c 100644\r
64 --- a/notmuch.c\r
65 +++ b/notmuch.c\r
66 @@ -29,7 +29,6 @@ typedef struct command {\r
67      command_function_t function;\r
68      const char *arguments;\r
69      const char *summary;\r
70 -    const char *documentation;\r
71  } command_t;\r
72  \r
73  #define MAX_ALIAS_SUBSTITUTIONS 3\r
74 @@ -47,447 +46,40 @@ alias_t aliases[] = {\r
75  static int\r
76  notmuch_help_command (void *ctx, int argc, char *argv[]);\r
77  \r
78 -static const char search_terms_help[] =\r
79 -    "\tSeveral notmuch commands accept a common syntax for search\n"\r
80 -    "\tterms.\n"\r
81 -    "\n"\r
82 -    "\tThe search terms can consist of free-form text (and quoted\n"\r
83 -    "\tphrases) which will match all messages that contain all of\n"\r
84 -    "\tthe given terms/phrases in the body, the subject, or any of\n"\r
85 -    "\tthe sender or recipient headers.\n"\r
86 -    "\n"\r
87 -    "\tAs a special case, a search string consisting of exactly a\n"\r
88 -    "\tsingle asterisk (\"*\") will match all messages.\n"\r
89 -    "\n"\r
90 -    "\tIn addition to free text, the following prefixes can be used\n"\r
91 -    "\tto force terms to match against specific portions of an email,\n"\r
92 -    "\t(where <brackets> indicate user-supplied values):\n"\r
93 -    "\n"\r
94 -    "\t\tfrom:<name-or-address>\n"\r
95 -    "\t\tto:<name-or-address>\n"\r
96 -    "\t\tsubject:<word-or-quoted-phrase>\n"\r
97 -    "\t\tattachment:<word>\n"\r
98 -    "\t\ttag:<tag> (or is:<tag>)\n"\r
99 -    "\t\tid:<message-id>\n"\r
100 -    "\t\tthread:<thread-id>\n"\r
101 -    "\t\tfolder:<directory-path>\n"\r
102 -    "\n"\r
103 -    "\tThe from: prefix is used to match the name or address of\n"\r
104 -    "\tthe sender of an email message.\n"\r
105 -    "\n"\r
106 -    "\tThe to: prefix is used to match the names or addresses of\n"\r
107 -    "\tany recipient of an email message, (whether To, Cc, or Bcc).\n"\r
108 -    "\n"\r
109 -    "\tAny term prefixed with subject: will match only text from\n"\r
110 -    "\tthe subject of an email. Quoted phrases are supported when\n"\r
111 -    "\tsearching with: subject:\"this is a phrase\".\n"\r
112 -    "\n"\r
113 -    "\tFor tag: and is:, valid tag values include \"inbox\" and \"unread\"\n"\r
114 -    "\tby default for new messages added by \"notmuch new\" as well\n"\r
115 -    "\tas any other tag values added manually with \"notmuch tag\".\n"\r
116 -    "\n"\r
117 -    "\tFor id:, message ID values are the literal contents of the\n"\r
118 -    "\tMessage-ID: header of email messages, but without the '<','>'\n"\r
119 -    "\tdelimiters.\n"\r
120 -    "\n"\r
121 -    "\tThe thread: prefix can be used with the thread ID values that\n"\r
122 -    "\tare generated internally by notmuch (and do not appear in email\n"\r
123 -    "\tmessages). These thread ID values can be seen in the first\n"\r
124 -    "\tcolumn of output from \"notmuch search\".\n"\r
125 -    "\n"\r
126 -    "\tThe folder: prefix can be used to search for email message\n"\r
127 -    "\tfiles that are contained within particular directories within\n"\r
128 -    "\tthe mail store. Only the directory components below the top-level\n"\r
129 -    "\tmail database path are available to be searched.\n"\r
130 -    "\n"\r
131 -    "\tIn addition to individual terms, multiple terms can be\n"\r
132 -    "\tcombined with Boolean operators (\"and\", \"or\", \"not\", etc.).\n"\r
133 -    "\tEach term in the query will be implicitly connected by a\n"\r
134 -    "\tlogical AND if no explicit operator is provided, (except\n"\r
135 -    "\tthat terms with a common prefix will be implicitly combined\n"\r
136 -    "\twith OR until we get Xapian defect #402 fixed).\n"\r
137 -    "\n"\r
138 -    "\tParentheses can also be used to control the combination of\n"\r
139 -    "\tthe Boolean operators, but will have to be protected from\n"\r
140 -    "\tinterpretation by the shell, (such as by putting quotation\n"\r
141 -    "\tmarks around any parenthesized expression).\n"\r
142 -    "\n"\r
143 -    "\tFinally, results can be restricted to only messages within a\n"\r
144 -    "\tparticular time range, (based on the Date: header) with:\n"\r
145 -    "\n"\r
146 -    "\t\t<intial-timestamp>..<final-timestamp>\n"\r
147 -    "\n"\r
148 -    "\tEach timestamp is a number representing the number of seconds\n"\r
149 -    "\tsince 1970-01-01 00:00:00 UTC. This is not the most convenient\n"\r
150 -    "\tmeans of expressing date ranges, but until notmuch is fixed to\n"\r
151 -    "\taccept a more convenient form, one can use the date program to\n"\r
152 -    "\tconstruct timestamps. For example, with the bash shell the\n"\r
153 -    "\tfollowing syntax would specify a date range to return messages\n"\r
154 -    "\tfrom 2009-10-01 until the current time:\n"\r
155 -    "\n"\r
156 -    "\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n";\r
157 -\r
158 -static const char hooks_help[] =\r
159 -    "\tHooks are scripts (or arbitrary executables or symlinks to such) that\n"\r
160 -    "\tnotmuch invokes before and after certain actions. These scripts reside\n"\r
161 -    "\tin the .notmuch/hooks directory within the database directory and must\n"\r
162 -    "\thave executable permissions.\n"\r
163 -    "\n"\r
164 -    "\tThe currently available hooks are described below.\n"\r
165 -    "\n"\r
166 -    "\tpre-new\n"\r
167 -    "\t\tThis hook is invoked by the new command before scanning or\n"\r
168 -    "\t\timporting new messages into the database. If this hook exits\n"\r
169 -    "\t\twith a non-zero status, notmuch will abort further processing\n"\r
170 -    "\t\tof the new command.\n"\r
171 -    "\n"\r
172 -    "\t\tTypically this hook is used for fetching or delivering new\n"\r
173 -    "\t\tmail to be imported into the database.\n"\r
174 -    "\n"\r
175 -    "\tpost-new\n"\r
176 -    "\t\tThis hook is invoked by the new command after new messages\n"\r
177 -    "\t\thave been imported into the database and initial tags have\n"\r
178 -    "\t\tbeen applied. The hook will not be run if there have been any\n"\r
179 -    "\t\terrors during the scan or import.\n"\r
180 -    "\n"\r
181 -    "\t\tTypically this hook is used to perform additional query-based\n"\r
182 -    "\t\ttagging on the imported messages.\n\n";\r
183 -\r
184  static command_t commands[] = {\r
185      { "setup", notmuch_setup_command,\r
186        NULL,\r
187 -      "Interactively setup notmuch for first use.",\r
188 -      "\tThe setup command will prompt for your full name, your primary\n"\r
189 -      "\temail address, any alternate email addresses you use, and the\n"\r
190 -      "\tdirectory containing your email archives. Your answers will be\n"\r
191 -      "\twritten to a configuration file in ${NOTMUCH_CONFIG} (if set)\n"\r
192 -      "\tor ${HOME}/.notmuch-config.\n"\r
193 -      "\n"\r
194 -      "\tThis configuration file will be created with descriptive\n"\r
195 -      "\tcomments, making it easy to edit by hand later to change the\n"\r
196 -      "\tconfiguration. Or you can run \"notmuch setup\" again.\n"\r
197 -      "\n"\r
198 -      "\tInvoking notmuch with no command argument will run setup if\n"\r
199 -      "\tthe setup command has not previously been completed." },\r
200 +      "Interactively setup notmuch for first use." },\r
201      { "new", notmuch_new_command,\r
202        "[options...]",\r
203 -      "Find and import new messages to the notmuch database.",\r
204 -      "\tScans all sub-directories of the mail directory, performing\n"\r
205 -      "\tfull-text indexing on new messages that are found. Each new\n"\r
206 -      "\tmessage will be tagged as both \"inbox\" and \"unread\".\n"\r
207 -      "\n"\r
208 -      "\tYou should run \"notmuch new\" once after first running\n"\r
209 -      "\t\"notmuch setup\" to create the initial database. The first\n"\r
210 -      "\trun may take a long time if you have a significant amount of\n"\r
211 -      "\tmail (several hundred thousand messages or more).\n"\r
212 -      "\n"\r
213 -      "\tSubsequently, you should run \"notmuch new\" whenever new mail\n"\r
214 -      "\tis delivered and you wish to incorporate it into the database.\n"\r
215 -      "\tThese subsequent runs will be much quicker than the initial run.\n"\r
216 -      "\n"\r
217 -      "\tThe new command supports hooks. See \"notmuch help hooks\" for\n"\r
218 -      "\tmore details on hooks.\n"\r
219 -      "\n"\r
220 -      "\tSupported options for new include:\n"\r
221 -      "\n"\r
222 -      "\t--no-hooks\n"\r
223 -      "\n"\r
224 -      "\t\tPrevent hooks from being run.\n"\r
225 -      "\n"\r
226 -      "\t--verbose\n"\r
227 -      "\n"\r
228 -      "\t\tVerbose operation. Shows paths of message files as\n"\r
229 -      "\t\tthey are being indexed.\n"\r
230 -      "\n"\r
231 -      "\tInvoking notmuch with no command argument will run new if\n"\r
232 -      "\tthe setup command has previously been completed, but new has\n"\r
233 -      "\tnot previously been run." },\r
234 +      "Find and import new messages to the notmuch database." },\r
235      { "search", notmuch_search_command,\r
236        "[options...] <search-terms> [...]",\r
237 -      "Search for messages matching the given search terms.",\r
238 -      "\tNote that the individual mail messages will be matched\n"\r
239 -      "\tagainst the search terms, but the results will be the\n"\r
240 -      "\tthreads (one per line) containing the matched messages.\n"\r
241 -      "\n"\r
242 -      "\tSupported options for search include:\n"\r
243 -      "\n"\r
244 -      "\t--format=(json|text)\n"\r
245 -      "\n"\r
246 -      "\t\tPresents the results in either JSON or\n"\r
247 -      "\t\tplain-text (default)\n"\r
248 -      "\n"\r
249 -      "\t--output=(summary|threads|messages|files|tags)\n"\r
250 -      "\n"\r
251 -      "\t\tsummary (default)\n"\r
252 -      "\n"\r
253 -      "\t\tOutput a summary of each thread with any message matching the\n"\r
254 -      "\t\tsearch terms. The summary includes the thread ID, date, the\n"\r
255 -      "\t\tnumber of messages in the thread (both the number matched and\n"\r
256 -      "\t\tthe total number), the authors of the thread and the subject.\n"\r
257 -      "\n"\r
258 -      "\t\tthreads\n"\r
259 -      "\n"\r
260 -      "\t\tOutput the thread IDs of all threads with any message matching\n"\r
261 -      "\t\tthe search terms, either one per line (--format=text) or as a\n"\r
262 -      "\t\tJSON array (--format=json).\n"\r
263 -      "\n"\r
264 -      "\t\tmessages\n"\r
265 -      "\n"\r
266 -      "\t\tOutput the message IDs of all messages matching the search\n"\r
267 -      "\t\tterms, either one per line (--format=text) or as a JSON array\n"\r
268 -      "\t\t(--format=json).\n"\r
269 -      "\n"\r
270 -      "\t\tfiles\n"\r
271 -      "\n"\r
272 -      "\t\tOutput the filenames of all messages matching the search\n"\r
273 -      "\t\tterms, either one per line (--format=text) or as a JSON array\n"\r
274 -      "\t\t(--format=json).\n"\r
275 -      "\n"\r
276 -      "\t\ttags\n"\r
277 -      "\n"\r
278 -      "\t\tOutput all tags that appear on any message matching the search\n"\r
279 -      "\t\tterms, either one per line (--format=text) or as a JSON array\n"\r
280 -      "\t\t(--format=json).\n"\r
281 -      "\n"\r
282 -      "\t--sort=(newest-first|oldest-first)\n"\r
283 -      "\n"\r
284 -      "\t\tPresent results in either chronological order\n"\r
285 -      "\t\t(oldest-first) or reverse chronological order\n"\r
286 -      "\t\t(newest-first), which is the default.\n"\r
287 -      "\n"\r
288 -      "\t--offset=[-]N\n"\r
289 -      "\n"\r
290 -      "\t\tSkip displaying the first N results. With the leading '-',\n"\r
291 -      "\t\tstart at the Nth result from the end.\n"\r
292 -      "\n"\r
293 -      "\t--limit=N\n"\r
294 -      "\n"\r
295 -      "\t\tLimit the number of displayed results to N.\n"\r
296 -      "\n"\r
297 -      "\tSee \"notmuch help search-terms\" for details of the search\n"\r
298 -      "\tterms syntax." },\r
299 +      "Search for messages matching the given search terms." },\r
300      { "show", notmuch_show_command,\r
301        "<search-terms> [...]",\r
302 -      "Show all messages matching the search terms.",\r
303 -      "\tThe messages are grouped and sorted based on the threading\n"\r
304 -      "\t(all replies to a particular message appear immediately\n"\r
305 -      "\tafter that message in date order).\n"\r
306 -      "\n"\r
307 -      "\tSupported options for show include:\n"\r
308 -      "\n"\r
309 -      "\t--entire-thread\n"\r
310 -      "\n"\r
311 -      "\t\tBy default only those messages that match the\n"\r
312 -      "\t\tsearch terms will be displayed. With this option,\n"\r
313 -      "\t\tall messages in the same thread as any matched\n"\r
314 -      "\t\tmessage will be displayed.\n"\r
315 -      "\n"\r
316 -      "\t--format=(text|json|mbox|raw)\n"\r
317 -      "\n"\r
318 -      "\t\ttext (default for messages)\n"\r
319 -      "\n"\r
320 -      "\t\tThe default plain-text format has all text-content MIME parts\n"\r
321 -      "\t\tdecoded. Various components in the output, ('message', 'header',\n"\r
322 -      "\t\t'body', 'attachment', and MIME 'part') are delimited by\n"\r
323 -      "\t\teasily-parsed markers. Each marker consists of a Control-L\n"\r
324 -      "\t\tcharacter (ASCII decimal 12), the name of the marker, and\n"\r
325 -      "\t\tthen either an opening or closing brace, '{' or '}' to\n"\r
326 -      "\t\teither open or close the component. For a multipart MIME\n"\r
327 -      "\t\tmessage, these parts will be nested.\n"\r
328 -      "\n"\r
329 -      "\t\tjson\n"\r
330 -      "\n"\r
331 -      "\t\tThe output is formatted with Javascript Object Notation\n"\r
332 -      "\t\t(JSON). This format is more robust than the text format\n"\r
333 -      "\t\tfor automated processing. The nested structure of multipart\n"\r
334 -      "\t\tMIME messages is reflected in nested JSON output. JSON\n"\r
335 -      "\t\toutput always includes all messages in a matching thread;\n"\r
336 -      "\t\tin effect '--format=json' implies '--entire-thread'\n"\r
337 -      "\n"\r
338 -      "\t\tmbox\n"\r
339 -      "\n"\r
340 -      "\t\tAll matching messages are output in the traditional, Unix\n"\r
341 -      "\t\tmbox format with each message being prefixed by a line\n"\r
342 -      "\t\tbeginning with 'From ' and a blank line separating each\n"\r
343 -      "\t\tmessage. Lines in the message content beginning with 'From '\n"\r
344 -      "\t\t(preceded by zero or more '>' characters) have an additional\n"\r
345 -      "\t\t'>' character added. This reversible escaping is termed\n"\r
346 -      "\t\t\"mboxrd\" format and described in detail here:\n"\r
347 -      "\n"\r
348 -      "\t\thttp://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html\n"\r
349 -      "\n"\r
350 -      "\t\traw (default for a single part, see --part)\n"\r
351 -      "\n"\r
352 -      "\t\tFor a message, the original, raw content of the email\n"\r
353 -      "\t\tmessage is output. Consumers of this format should\n"\r
354 -      "\t\texpect to implement MIME decoding and similar functions.\n"\r
355 -      "\n"\r
356 -      "\t\tFor a single part (--part) the raw part content is output\n"\r
357 -      "\t\tafter performing any necessary MIME decoding.\n"\r
358 -      "\n"\r
359 -      "\t\tThe raw format must only be used with search terms matching\n"\r
360 -      "\t\tsingle message.\n"\r
361 -      "\n"\r
362 -      "\t--part=N\n"\r
363 -      "\n"\r
364 -      "\t\tOutput the single decoded MIME part N of a single message.\n"\r
365 -      "\t\tThe search terms must match only a single message.\n"\r
366 -      "\t\tMessage parts are numbered in a depth-first walk of the\n"\r
367 -      "\t\tmessage MIME structure, and are identified in the 'json' or\n"\r
368 -      "\t\t'text' output formats.\n"\r
369 -      "\n"\r
370 -      "\t--verify\n"\r
371 -      "\n"\r
372 -      "\t\tCompute and report the validity of any MIME cryptographic\n"\r
373 -      "\t\tsignatures found in the selected content (ie.\n"\r
374 -      "\t\t\"multipart/signed\" parts). Status of the signature will be\n"\r
375 -      "\t\treported (currently only supported with --format=json) and\n"\r
376 -      "\t\tthe multipart/signed part will be replaced by the signed data.\n"\r
377 -      "\n"\r
378 -      "\t--decrypt\n"\r
379 -      "\n"\r
380 -      "\t\tDecrypt any MIME encrypted parts found in the selected content\n"\r
381 -      "\t\t(ie. \"multipart/encrypted\" parts). Status of the decryption\n"\r
382 -      "\t\twill be reported (currently only supported with --format=json)\n"\r
383 -      "\t\tand the multipart/encrypted part will be replaced by the\n"\r
384 -      "\t\tdecrypted content.\n"\r
385 -      "\n"\r
386 -      "\n"\r
387 -      "\tA common use of \"notmuch show\" is to display a single\n"\r
388 -      "\tthread of email messages. For this, use a search term of\n"\r
389 -      "\t\"thread:<thread-id>\" as can be seen in the first column\n"\r
390 -      "\tof output from the \"notmuch search\" command.\n"\r
391 -      "\n"\r
392 -      "\tSee \"notmuch help search-terms\" for details of the search\n"\r
393 -      "\tterms syntax." },\r
394 +      "Show all messages matching the search terms." },\r
395      { "count", notmuch_count_command,\r
396        "[options...] <search-terms> [...]",\r
397 -      "Count messages matching the search terms.",\r
398 -      "\tThe number of matching messages (or threads) is output to stdout.\n"\r
399 -      "\n"\r
400 -      "\tWith no search terms, a count of all messages (or threads) in\n"\r
401 -      "\tthe database will be displayed.\n"\r
402 -      "\n"\r
403 -      "\tSupported options for count include:\n"\r
404 -      "\n"\r
405 -      "\t--output=(messages|threads)\n"\r
406 -      "\n"\r
407 -      "\t\tmessages (default)\n"\r
408 -      "\n"\r
409 -      "\t\tOutput the number of matching messages.\n"\r
410 -      "\n"\r
411 -      "\t\tthreads\n"\r
412 -      "\n"\r
413 -      "\t\tOutput the number of matching threads.\n"\r
414 -      "\n"\r
415 -      "\tSee \"notmuch help search-terms\" for details of the search\n"\r
416 -      "\tterms syntax." },\r
417 +      "Count messages matching the search terms." },\r
418      { "reply", notmuch_reply_command,\r
419        "[options...] <search-terms> [...]",\r
420 -      "Construct a reply template for a set of messages.",\r
421 -      "\tConstructs a new message as a reply to a set of existing\n"\r
422 -      "\tmessages. The Reply-To: header (if any, otherwise From:) is\n"\r
423 -      "\tused for the To: address. The To: and Cc: headers are copied,\n"\r
424 -      "\tbut not including any of the user's configured addresses.\n"\r
425 -      "\n"\r
426 -      "\tA suitable subject is constructed. The In-Reply-to: and\n"\r
427 -      "\tReferences: headers are set appropriately, and the content\n"\r
428 -      "\tof the original messages is quoted and included in the body\n"\r
429 -      "\t(unless --format=headers-only is given).\n"\r
430 -      "\n"\r
431 -      "\tThe resulting message template is output to stdout.\n"\r
432 -      "\n"\r
433 -      "\tSupported options for reply include:\n"\r
434 -      "\n"\r
435 -      "\t--format=(default|headers-only)\n"\r
436 -      "\n"\r
437 -      "\t\tdefault:\n"\r
438 -      "\t\t\tIncludes subject and quoted message body.\n"\r
439 -      "\n"\r
440 -      "\t\theaders-only:\n"\r
441 -      "\t\t\tOnly produces In-Reply-To, References, To\n"\r
442 -      "\t\t\tCc, and Bcc headers.\n"\r
443 -      "\n"\r
444 -      "\tSee \"notmuch help search-terms\" for details of the search\n"\r
445 -      "\tterms syntax." },\r
446 +      "Construct a reply template for a set of messages." },\r
447      { "tag", notmuch_tag_command,\r
448 -      "+<tag>|-<tag> [...] [--] <search-terms> [...]",\r
449 -      "Add/remove tags for all messages matching the search terms.",\r
450 -      "\tThe search terms are handled exactly as in 'search' so one\n"\r
451 -      "\tcan use that command first to see what will be modified.\n"\r
452 -      "\n"\r
453 -      "\tTags prefixed by '+' are added while those prefixed by\n"\r
454 -      "\t'-' are removed. For each message, tag removal is performed\n"\r
455 -      "\tbefore tag addition.\n"\r
456 -      "\n"\r
457 -      "\tThe beginning of <search-terms> is recognized by the first\n"\r
458 -      "\targument that begins with neither '+' nor '-'. Support for\n"\r
459 -      "\tan initial search term beginning with '+' or '-' is provided\n"\r
460 -      "\tby allowing the user to specify a \"--\" argument to separate\n"\r
461 -      "\tthe tags from the search terms.\n"\r
462 -      "\n"\r
463 -      "\tSee \"notmuch help search-terms\" for details of the search\n"\r
464 -      "\tterms syntax." },\r
465 +      "+<tag>|-<tag> [...] [--] <search-terms> [...]" ,\r
466 +      "Add/remove tags for all messages matching the search terms." },\r
467      { "dump", notmuch_dump_command,\r
468        "[<filename>] [--] [<search-terms>]",\r
469 -      "Create a plain-text dump of the tags for each message.",\r
470 -      "\tOutput is to the given filename, if any, or to stdout.\n"\r
471 -      "\tNote that using the filename argument is deprecated.\n"\r
472 -      "\n"\r
473 -      "\tThese tags are the only data in the notmuch database\n"\r
474 -      "\tthat can't be recreated from the messages themselves.\n"\r
475 -      "\tThe output of notmuch dump is therefore the only\n"\r
476 -      "\tcritical thing to backup (and much more friendly to\n"\r
477 -      "\tincremental backup than the native database files.)\n" \r
478 -      "\n"\r
479 -      "\tWith no search terms, a dump of all messages in the\n"\r
480 -      "\tdatabase will be generated. A \"--\" argument instructs\n"\r
481 -      "\tnotmuch that the remaining arguments are search terms.\n"\r
482 -      "\n"\r
483 -      "\tSee \"notmuch help search-terms\" for the search-term syntax.\n"      \r
484 - },\r
485 +      "Create a plain-text dump of the tags for each message." },\r
486      { "restore", notmuch_restore_command,\r
487        "[--accumulate] [<filename>]",\r
488 -      "Restore the tags from the given dump file (see 'dump').",\r
489 -      "\tInput is read from the given filename, if any, or from stdin.\n"\r
490 -      "\tNote: The dump file format is specifically chosen to be\n"\r
491 -      "\tcompatible with the format of files produced by sup-dump.\n"\r
492 -      "\tSo if you've previously been using sup for mail, then the\n"\r
493 -      "\t\"notmuch restore\" command provides you a way to import\n"\r
494 -      "\tall of your tags (or labels as sup calls them).\n"\r
495 -      "\tThe --accumulate switch causes the union of the existing and new\n"\r
496 -      "\ttags to be applied, instead of replacing each message's tags as\n"\r
497 -      "\tthey are read in from the dump file."},\r
498 +      "Restore the tags from the given dump file (see 'dump')." },\r
499      { "config", notmuch_config_command,\r
500        "[get|set] <section>.<item> [value ...]",\r
501 -      "Get or set settings in the notmuch configuration file.",\r
502 -      "    config get <section>.<item>\n"\r
503 -      "\n"\r
504 -      "\tThe value of the specified configuration item is printed\n"\r
505 -      "\tto stdout. If the item has multiple values, each value\n"\r
506 -      "\tis separated by a newline character.\n"\r
507 -      "\n"\r
508 -      "\tAvailable configuration items include at least\n"\r
509 -      "\n"\r
510 -      "\t\tdatabase.path\n"\r
511 -      "\t\tuser.name\n"\r
512 -      "\t\tuser.primary_email\n"\r
513 -      "\t\tuser.other_email\n"\r
514 -      "\t\tnew.tags\n"\r
515 -      "\n"\r
516 -      "    config set <section>.<item> [value ...]\n"\r
517 -      "\n"\r
518 -      "\tThe specified configuration item is set to the given value.\n"\r
519 -      "\tTo specify a multiple-value item, provide each value as\n"\r
520 -      "\ta separate command-line argument.\n"\r
521 -      "\n"\r
522 -      "\tIf no values are provided, the specified configuration item\n"\r
523 -      "\twill be removed from the configuration file." },\r
524 +      "Get or set settings in the notmuch configuration file." },\r
525      { "help", notmuch_help_command,\r
526        "[<command>]",\r
527 -      "This message, or more detailed help for the named command.",\r
528 -      "\tExcept in this case, where there's not much more detailed\n"\r
529 -      "\thelp available." }\r
530 +      "This message, or more detailed help for the named command." }\r
531  };\r
532  \r
533  static void\r
534 @@ -517,8 +109,17 @@ usage (FILE *out)\r
535      "and \"notmuch help search-terms\" for the common search-terms syntax.\n\n");\r
536  }\r
537  \r
538 +static void\r
539 +exec_man (const char *page)\r
540 +{\r
541 +    if (execlp ("man", "man", page, (char *) NULL)) {\r
542 +       perror ("exec man");\r
543 +       exit (1);\r
544 +    }\r
545 +}\r
546 +\r
547  static int\r
548 -notmuch_help_command (unused (void *ctx), int argc, char *argv[])\r
549 +notmuch_help_command (void *ctx, int argc, char *argv[])\r
550  {\r
551      command_t *command;\r
552      unsigned int i;\r
553 @@ -531,41 +132,28 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])\r
554         return 0;\r
555      }\r
556  \r
557 +    if (strcmp (argv[0], "help") == 0) {\r
558 +       printf ("The notmuch help system.\n\n"\r
559 +               "\tNotmuch uses the man command to display help. In case\n"\r
560 +               "\tof difficulties check that MANPATH includes the pages\n"\r
561 +               "\tinstalled by notmuch.\n\n"\r
562 +               "\tTry \"notmuch help\" for a list of topics.\n");\r
563 +       return 0;\r
564 +    }\r
565 +\r
566      for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
567         command = &commands[i];\r
568  \r
569         if (strcmp (argv[0], command->name) == 0) {\r
570 -           printf ("Help for \"notmuch %s\":\n\n", argv[0]);\r
571 -           if (command->arguments)\r
572 -               printf ("%s %s\n\n\t%s\n\n%s\n\n",\r
573 -                       command->name, command->arguments,\r
574 -                       command->summary, command->documentation);\r
575 -           else\r
576 -               printf ("%s\t%s\n\n%s\n\n", command->name,\r
577 -                       command->summary, command->documentation);\r
578 -           return 0;\r
579 +           char *page = talloc_asprintf (ctx, "notmuch-%s", command->name);\r
580 +           exec_man (page);\r
581         }\r
582      }\r
583  \r
584      if (strcmp (argv[0], "search-terms") == 0) {\r
585 -       printf ("Help for <%s>\n\n", argv[0]);\r
586 -       for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
587 -           command = &commands[i];\r
588 -\r
589 -           if (command->arguments &&\r
590 -               strstr (command->arguments, "search-terms"))\r
591 -           {\r
592 -               printf ("\t%s\t%s\n",\r
593 -                       command->name, command->arguments);\r
594 -           }\r
595 -       }\r
596 -       printf ("\n");\r
597 -       printf (search_terms_help);\r
598 -       return 0;\r
599 +       exec_man ("notmuch-search-terms");\r
600      } else if (strcmp (argv[0], "hooks") == 0) {\r
601 -       printf ("Help for <%s>\n\n", argv[0]);\r
602 -       printf (hooks_help);\r
603 -       return 0;\r
604 +       exec_man ("notmuch-hooks");\r
605      }\r
606  \r
607      fprintf (stderr,\r
608 -- \r
609 1.7.7.3\r
610 \r