1 Return-Path: <bremner@unb.ca>
\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 69E2A4196F2
\r
6 for <notmuch@notmuchmail.org>; Wed, 3 Nov 2010 10:19:59 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
\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 Hu2a5CggnsLU for <notmuch@notmuchmail.org>;
\r
16 Wed, 3 Nov 2010 10:19:47 -0700 (PDT)
\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 1713740D155
\r
21 for <notmuch@notmuchmail.org>; Wed, 3 Nov 2010 10:19:36 -0700 (PDT)
\r
22 Received: from rocinante.cs.unb.ca
\r
23 (fctnnbsc30w-142167176217.pppoe-dynamic.High-Speed.nb.bellaliant.net
\r
24 [142.167.176.217]) (authenticated bits=0)
\r
25 by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id oA3HJYJp014339
\r
26 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
\r
27 Wed, 3 Nov 2010 14:19:34 -0300
\r
28 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.72)
\r
29 (envelope-from <bremner@unb.ca>)
\r
30 id 1PDgzm-0001P5-BR; Wed, 03 Nov 2010 14:19:34 -0300
\r
31 From: david@tethera.net
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH 4/4] notmuch.c: use help strings generated from notmuch.pod.
\r
34 Date: Wed, 3 Nov 2010 14:18:56 -0300
\r
35 Message-Id: <1288804736-5173-5-git-send-email-david@tethera.net>
\r
36 X-Mailer: git-send-email 1.7.1
\r
37 In-Reply-To: <874oc4r4bu.fsf@yoom.home.cworth.org>
\r
38 References: <874oc4r4bu.fsf@yoom.home.cworth.org>
\r
39 Cc: David Bremner <bremner@unb.ca>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\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: Wed, 03 Nov 2010 17:19:59 -0000
\r
54 From: David Bremner <bremner@unb.ca>
\r
56 It is quite possible this could be more automagically generated; there
\r
57 is a certain amount of boilerplate in typing HELP_command_args,
\r
58 HELP_command_desc, HELP_command_text. But, this way is less error
\r
61 notmuch.c | 388 +++++++++----------------------------------------------------
\r
62 1 files changed, 54 insertions(+), 334 deletions(-)
\r
64 diff --git a/notmuch.c b/notmuch.c
\r
65 index 030e494..d1ae366 100644
\r
71 #include "notmuch-client.h"
\r
72 +#include "notmuch-help.h"
\r
74 typedef int (*command_function_t) (void *ctx, int argc, char *argv[]);
\r
76 @@ -36,354 +37,73 @@ static int
\r
77 notmuch_help_command (void *ctx, int argc, char *argv[]);
\r
79 static const char search_terms_help[] =
\r
80 - "\tSeveral notmuch commands accept a comman syntax for search\n"
\r
83 - "\tThe search terms can consist of free-form text (and quoted\n"
\r
84 - "\tphrases) which will match all messages that contain all of\n"
\r
85 - "\tthe given terms/phrases in the body, the subject, or any of\n"
\r
86 - "\tthe sender or recipient headers.\n"
\r
88 - "\tAs a special case, a search string consisting of exactly a\n"
\r
89 - "\tsingle asterisk (\"*\") will match all messages.\n"
\r
91 - "\tIn addition to free text, the following prefixes can be used\n"
\r
92 - "\tto force terms to match against specific portions of an email,\n"
\r
93 - "\t(where <brackets> indicate user-supplied values):\n"
\r
95 - "\t\tfrom:<name-or-address>\n"
\r
96 - "\t\tto:<name-or-address>\n"
\r
97 - "\t\tsubject:<word-or-quoted-phrase>\n"
\r
98 - "\t\tattachment:<word>\n"
\r
99 - "\t\ttag:<tag> (or is:<tag>)\n"
\r
100 - "\t\tid:<message-id>\n"
\r
101 - "\t\tthread:<thread-id>\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
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
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
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
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
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
126 - "\tIn addition to individual terms, multiple terms can be\n"
\r
127 - "\tcombined with Boolean operators (\"and\", \"or\", \"not\", etc.).\n"
\r
128 - "\tEach term in the query will be implicitly connected by a\n"
\r
129 - "\tlogical AND if no explicit operator is provided, (except\n"
\r
130 - "\tthat terms with a common prefix will be implicitly combined\n"
\r
131 - "\twith OR until we get Xapian defect #402 fixed).\n"
\r
133 - "\tParentheses can also be used to control the combination of\n"
\r
134 - "\tthe Boolean operators, but will have to be protected from\n"
\r
135 - "\tinterpretation by the shell, (such as by putting quotation\n"
\r
136 - "\tmarks around any parenthesized expression).\n"
\r
138 - "\tFinally, results can be restricted to only messages within a\n"
\r
139 - "\tparticular time range, (based on the Date: header) with:\n"
\r
141 - "\t\t<intial-timestamp>..<final-timestamp>\n"
\r
143 - "\tEach timestamp is a number representing the number of seconds\n"
\r
144 - "\tsince 1970-01-01 00:00:00 UTC. This is not the most convenient\n"
\r
145 - "\tmeans of expressing date ranges, but until notmuch is fixed to\n"
\r
146 - "\taccept a more convenient form, one can use the date program to\n"
\r
147 - "\tconstruct timestamps. For example, with the bash shell the\n"
\r
148 - "\tfollowing syntax would specify a date range to return messages\n"
\r
149 - "\tfrom 2009-10-01 until the current time:\n"
\r
151 - "\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n";
\r
152 + HELP_search_syntax_text;
\r
154 command_t commands[] = {
\r
155 { "setup", notmuch_setup_command,
\r
157 - "Interactively setup notmuch for first use.",
\r
158 - "\tThe setup command will prompt for your full name, your primary\n"
\r
159 - "\temail address, any alternate email addresses you use, and the\n"
\r
160 - "\tdirectory containing your email archives. Your answers will be\n"
\r
161 - "\twritten to a configuration file in ${NOTMUCH_CONFIG} (if set)\n"
\r
162 - "\tor ${HOME}/.notmuch-config.\n"
\r
164 - "\tThis configuration file will be created with descriptive\n"
\r
165 - "\tcomments, making it easy to edit by hand later to change the\n"
\r
166 - "\tconfiguration. Or you can run \"notmuch setup\" again.\n"
\r
168 - "\tInvoking notmuch with no command argument will run setup if\n"
\r
169 - "\tthe setup command has not previously been completed." },
\r
172 + HELP_setup_text },
\r
173 { "new", notmuch_new_command,
\r
175 - "Find and import new messages to the notmuch database.",
\r
176 - "\tScans all sub-directories of the mail directory, performing\n"
\r
177 - "\tfull-text indexing on new messages that are found. Each new\n"
\r
178 - "\tmessage will be tagged as both \"inbox\" and \"unread\".\n"
\r
180 - "\tYou should run \"notmuch new\" once after first running\n"
\r
181 - "\t\"notmuch setup\" to create the initial database. The first\n"
\r
182 - "\trun may take a long time if you have a significant amount of\n"
\r
183 - "\tmail (several hundred thousand messages or more).\n"
\r
185 - "\tSubsequently, you should run \"notmuch new\" whenever new mail\n"
\r
186 - "\tis delivered and you wish to incorporate it into the database.\n"
\r
187 - "\tThese subsequent runs will be much quicker than the initial run.\n"
\r
189 - "\tSupported options for new include:\n"
\r
193 - "\t\tVerbose operation. Shows paths of message files as\n"
\r
194 - "\t\tthey are being indexed.\n"
\r
196 - "\tInvoking notmuch with no command argument will run new if\n"
\r
197 - "\tthe setup command has previously been completed, but new has\n"
\r
198 - "\tnot previously been run." },
\r
202 { "search", notmuch_search_command,
\r
203 - "[options...] <search-terms> [...]",
\r
204 - "Search for messages matching the given search terms.",
\r
205 - "\tNote that the individual mail messages will be matched\n"
\r
206 - "\tagainst the search terms, but the results will be the\n"
\r
207 - "\tthreads (one per line) containing the matched messages.\n"
\r
209 - "\tSupported options for search include:\n"
\r
211 - "\t--format=(json|text)\n"
\r
213 - "\t\tPresents the results in either JSON or\n"
\r
214 - "\t\tplain-text (default)\n"
\r
216 - "\t--output=(summary|threads|messages|files|tags)\n"
\r
218 - "\t\tsummary (default)\n"
\r
220 - "\t\tOutput a summary of each thread with any message matching the\n"
\r
221 - "\t\tsearch terms. The summary includes the thread ID, date, the\n"
\r
222 - "\t\tnumber of messages in the thread (both the number matched and\n"
\r
223 - "\t\tthe total number), the authors of the thread and the subject.\n"
\r
227 - "\t\tOutput the thread IDs of all threads with any message matching\n"
\r
228 - "\t\tthe search terms, either one per line (--format=text) or as a\n"
\r
229 - "\t\tJSON array (--format=json).\n"
\r
233 - "\t\tOutput the message IDs of all messages matching the search\n"
\r
234 - "\t\tterms, either one per line (--format=text) or as a JSON array\n"
\r
235 - "\t\t(--format=json).\n"
\r
239 - "\t\tOutput the filenames of all messages matching the search\n"
\r
240 - "\t\tterms, either one per line (--format=text) or as a JSON array\n"
\r
241 - "\t\t(--format=json).\n"
\r
245 - "\t\tOutput all tags that appear on any message matching the search\n"
\r
246 - "\t\tterms, either one per line (--format=text) or as a JSON array\n"
\r
247 - "\t\t(--format=json).\n"
\r
249 - "\t--sort=(newest-first|oldest-first)\n"
\r
251 - "\t\tPresent results in either chronological order\n"
\r
252 - "\t\t(oldest-first) or reverse chronological order\n"
\r
253 - "\t\t(newest-first), which is the default.\n"
\r
255 - "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
256 - "\tterms syntax." },
\r
257 + HELP_search_args,
\r
258 + HELP_search_desc,
\r
261 { "show", notmuch_show_command,
\r
262 - "<search-terms> [...]",
\r
263 - "Show all messages matching the search terms.",
\r
264 - "\tThe messages are grouped and sorted based on the threading\n"
\r
265 - "\t(all replies to a particular message appear immediately\n"
\r
266 - "\tafter that message in date order).\n"
\r
268 - "\tSupported options for show include:\n"
\r
270 - "\t--entire-thread\n"
\r
272 - "\t\tBy default only those messages that match the\n"
\r
273 - "\t\tsearch terms will be displayed. With this option,\n"
\r
274 - "\t\tall messages in the same thread as any matched\n"
\r
275 - "\t\tmessage will be displayed.\n"
\r
277 - "\t--format=(text|json|mbox)\n"
\r
279 - "\t\ttext (default)\n"
\r
281 - "\t\tThe default plain-text format has all text-content MIME parts\n"
\r
282 - "\t\tdecoded. Various components in the output, ('message', 'header',\n"
\r
283 - "\t\t'body', 'attachment', and MIME 'part') are delimited by\n"
\r
284 - "\t\teasily-parsed markers. Each marker consists of a Control-L\n"
\r
285 - "\t\tcharacter (ASCII decimal 12), the name of the marker, and\n"
\r
286 - "\t\tthen either an opening or closing brace, '{' or '}' to\n"
\r
287 - "\t\teither open or close the component.\n"
\r
291 - "\t\tThe output is formatted with Javascript Object Notation\n"
\r
292 - "\t\t(JSON). This format is more robust than the text format\n"
\r
293 - "\t\tfor automated processing. JSON output always includes all\n"
\r
294 - "\t\tmessages in a matching thread; in effect '--format=json'\n"
\r
295 - "\t\timplies '--entire-thread'\n"
\r
299 - "\t\tAll matching messages are output in the traditional, Unix\n"
\r
300 - "\t\tmbox format with each message being prefixed by a line\n"
\r
301 - "\t\tbeginning with 'From ' and a blank line separating each\n"
\r
302 - "\t\tmessage. Lines in the message content beginning with 'From '\n"
\r
303 - "\t\t(preceded by zero or more '>' characters) have an additional\n"
\r
304 - "\t\t'>' character added. This reversible escaping is termed\n"
\r
305 - "\t\t\"mboxrd\" format and described in detail here:\n"
\r
307 - "\t\thttp://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html\n"
\r
309 - "\tA common use of \"notmuch show\" is to display a single\n"
\r
310 - "\tthread of email messages. For this, use a search term of\n"
\r
311 - "\t\"thread:<thread-id>\" as can be seen in the first column\n"
\r
312 - "\tof output from the \"notmuch search\" command.\n"
\r
314 - "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
315 - "\tterms syntax." },
\r
320 { "count", notmuch_count_command,
\r
321 - "<search-terms> [...]",
\r
322 - "Count messages matching the search terms.",
\r
323 - "\tThe number of matching messages is output to stdout.\n"
\r
325 - "\tWith no search terms, a count of all messages in the database\n"
\r
326 - "\twill be displayed.\n"
\r
328 - "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
329 - "\tterms syntax." },
\r
334 { "reply", notmuch_reply_command,
\r
335 - "[options...] <search-terms> [...]",
\r
336 - "Construct a reply template for a set of messages.",
\r
337 - "\tConstructs a new message as a reply to a set of existing\n"
\r
338 - "\tmessages. The Reply-To: header (if any, otherwise From:) is\n"
\r
339 - "\tused for the To: address. The To: and Cc: headers are copied,\n"
\r
340 - "\tbut not including any of the user's configured addresses.\n"
\r
342 - "\tA suitable subject is constructed. The In-Reply-to: and\n"
\r
343 - "\tReferences: headers are set appropriately, and the content\n"
\r
344 - "\tof the original messages is quoted and included in the body\n"
\r
345 - "\t(unless --format=headers-only is given).\n"
\r
347 - "\tThe resulting message template is output to stdout.\n"
\r
349 - "\tSupported options for reply include:\n"
\r
351 - "\t--format=(default|headers-only)\n"
\r
354 - "\t\t\tIncludes subject and quoted message body.\n"
\r
356 - "\t\theaders-only:\n"
\r
357 - "\t\t\tOnly produces In-Reply-To, References, To\n"
\r
358 - "\t\t\tCc, and Bcc headers.\n"
\r
360 - "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
361 - "\tterms syntax." },
\r
366 { "tag", notmuch_tag_command,
\r
367 - "+<tag>|-<tag> [...] [--] <search-terms> [...]",
\r
368 - "Add/remove tags for all messages matching the search terms.",
\r
369 - "\tThe search terms are handled exactly as in 'search' so one\n"
\r
370 - "\tcan use that command first to see what will be modified.\n"
\r
372 - "\tTags prefixed by '+' are added while those prefixed by\n"
\r
373 - "\t'-' are removed. For each message, tag removal is performed\n"
\r
374 - "\tbefore tag addition.\n"
\r
376 - "\tThe beginning of <search-terms> is recognized by the first\n"
\r
377 - "\targument that begins with neither '+' nor '-'. Support for\n"
\r
378 - "\tan initial search term beginning with '+' or '-' is provided\n"
\r
379 - "\tby allowing the user to specify a \"--\" argument to separate\n"
\r
380 - "\tthe tags from the search terms.\n"
\r
382 - "\tSee \"notmuch help search-terms\" for details of the search\n"
\r
383 - "\tterms syntax." },
\r
388 { "dump", notmuch_dump_command,
\r
390 - "Create a plain-text dump of the tags for each message.",
\r
391 - "\tOutput is to the given filename, if any, or to stdout.\n"
\r
392 - "\tThese tags are the only data in the notmuch database\n"
\r
393 - "\tthat can't be recreated from the messages themselves.\n"
\r
394 - "\tThe output of notmuch dump is therefore the only\n"
\r
395 - "\tcritical thing to backup (and much more friendly to\n"
\r
396 - "\tincremental backup than the native database files.)" },
\r
402 { "restore", notmuch_restore_command,
\r
404 - "Restore the tags from the given dump file (see 'dump').",
\r
405 - "\tNote: The dump file format is specifically chosen to be\n"
\r
406 - "\tcompatible with the format of files produced by sup-dump.\n"
\r
407 - "\tSo if you've previously been using sup for mail, then the\n"
\r
408 - "\t\"notmuch restore\" command provides you a way to import\n"
\r
409 - "\tall of your tags (or labels as sup calls them)." },
\r
410 + HELP_restore_args,
\r
411 + HELP_restore_desc,
\r
412 + HELP_restore_text
\r
414 { "search-tags", notmuch_search_tags_command,
\r
415 - "[<search-terms> [...] ]",
\r
416 - "List all tags found in the database or matching messages.",
\r
417 - "\tRun this command without any search-term(s) to obtain a list\n"
\r
418 - "\tof all tags found in the database. If you provide one or more\n"
\r
419 - "\tsearch-terms as argument(s) then the resulting list will\n"
\r
420 - "\tcontain tags only from messages that match the search-term(s).\n"
\r
422 - "\tIn both cases the list will be alphabetically sorted." },
\r
423 + HELP_search_tags_args,
\r
424 + HELP_search_tags_desc,
\r
425 + HELP_search_tags_text
\r
427 { "part", notmuch_part_command,
\r
428 - "--part=<num> <search-terms>",
\r
429 - "Output a single MIME part of a message.",
\r
430 - "\tA single decoded MIME part, with no encoding or framing,\n"
\r
431 - "\tis output to stdout. The search terms must match only a single\n"
\r
432 - "\tmessage, otherwise this command will fail.\n"
\r
434 - "\tThe part number should match the part \"id\" field output\n"
\r
435 - "\tby the \"--format=json\" option of \"notmuch show\". If the\n"
\r
436 - "\tmessage specified by the search terms does not include a\n"
\r
437 - "\tpart with the specified \"id\" there will be no output." },
\r
442 { "config", notmuch_config_command,
\r
443 - "[get|set] <section>.<item> [value ...]",
\r
444 - "Get or set settings in the notmuch configuration file.",
\r
445 - " config get <section>.<item>\n"
\r
447 - "\tThe value of the specified configuration item is printed\n"
\r
448 - "\tto stdout. If the item has multiple values, each value\n"
\r
449 - "\tis separated by a newline character.\n"
\r
451 - "\tAvailable configuration items include at least\n"
\r
453 - "\t\tdatabase.path\n"
\r
454 - "\t\tuser.name\n"
\r
455 - "\t\tuser.primary_email\n"
\r
456 - "\t\tuser.other_email\n"
\r
459 - " config set <section>.<item> [value ...]\n"
\r
461 - "\tThe specified configuration item is set to the given value.\n"
\r
462 - "\tTo specify a multiple-value item, provide each value as\n"
\r
463 - "\ta separate command-line argument.\n"
\r
465 - "\tIf no values are provided, the specified configuration item\n"
\r
466 - "\twill be removed from the configuration file." },
\r
467 + HELP_config_args,
\r
468 + HELP_config_desc,
\r
471 { "help", notmuch_help_command,
\r
473 - "This message, or more detailed help for the named command.",
\r
474 - "\tExcept in this case, where there's not much more detailed\n"
\r
475 - "\thelp available." }
\r
483 @@ -454,7 +174,7 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])
\r
487 - printf (search_terms_help);
\r
488 + fputs (search_terms_help, stdout);
\r