aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch.c
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2011-12-09 00:48:30 +0200
committerGravatar David Bremner <bremner@debian.org>2011-12-11 13:58:15 -0400
commit69bb7f35b6e59fd3a3b1fb2d0f0367f7016cba80 (patch)
tree0e92645d33017b082c28a3de6e82f73213300f74 /notmuch.c
parentd399b6b909fe6e2c6073464006061382c8bb31d5 (diff)
cli: add support for pre and post notmuch new hooks
Run notmuch new pre and post hooks, named "pre-new" and "post-new", if present in the notmuch hooks directory. The hooks will be run before and after incorporating new messages to the database. Typical use cases for pre-new and post-new hooks are fetching or delivering new mail to the maildir, and custom tagging of the mail incorporated to the database. Also add command line option --no-hooks to notmuch new to bypass the hooks. Signed-off-by: Jani Nikula <jani@nikula.org>
Diffstat (limited to 'notmuch.c')
-rw-r--r--notmuch.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/notmuch.c b/notmuch.c
index d44ce9a0..c0ce026a 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -127,6 +127,32 @@ static const char search_terms_help[] =
"\n"
"\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n";
+static const char hooks_help[] =
+ "\tHooks are scripts (or arbitrary executables or symlinks to such) that\n"
+ "\tnotmuch invokes before and after certain actions. These scripts reside\n"
+ "\tin the .notmuch/hooks directory within the database directory and must\n"
+ "\thave executable permissions.\n"
+ "\n"
+ "\tThe currently available hooks are described below.\n"
+ "\n"
+ "\tpre-new\n"
+ "\t\tThis hook is invoked by the new command before scanning or\n"
+ "\t\timporting new messages into the database. If this hook exits\n"
+ "\t\twith a non-zero status, notmuch will abort further processing\n"
+ "\t\tof the new command.\n"
+ "\n"
+ "\t\tTypically this hook is used for fetching or delivering new\n"
+ "\t\tmail to be imported into the database.\n"
+ "\n"
+ "\tpost-new\n"
+ "\t\tThis hook is invoked by the new command after new messages\n"
+ "\t\thave been imported into the database and initial tags have\n"
+ "\t\tbeen applied. The hook will not be run if there have been any\n"
+ "\t\terrors during the scan or import.\n"
+ "\n"
+ "\t\tTypically this hook is used to perform additional query-based\n"
+ "\t\ttagging on the imported messages.\n\n";
+
static command_t commands[] = {
{ "setup", notmuch_setup_command,
NULL,
@@ -144,7 +170,7 @@ static command_t commands[] = {
"\tInvoking notmuch with no command argument will run setup if\n"
"\tthe setup command has not previously been completed." },
{ "new", notmuch_new_command,
- "[--verbose]",
+ "[options...]",
"Find and import new messages to the notmuch database.",
"\tScans all sub-directories of the mail directory, performing\n"
"\tfull-text indexing on new messages that are found. Each new\n"
@@ -159,8 +185,15 @@ static command_t commands[] = {
"\tis delivered and you wish to incorporate it into the database.\n"
"\tThese subsequent runs will be much quicker than the initial run.\n"
"\n"
+ "\tThe new command supports hooks. See \"notmuch help hooks\" for\n"
+ "\tmore details on hooks.\n"
+ "\n"
"\tSupported options for new include:\n"
"\n"
+ "\t--no-hooks\n"
+ "\n"
+ "\t\tPrevent hooks from being run.\n"
+ "\n"
"\t--verbose\n"
"\n"
"\t\tVerbose operation. Shows paths of message files as\n"
@@ -529,6 +562,10 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])
printf ("\n");
printf (search_terms_help);
return 0;
+ } else if (strcmp (argv[0], "hooks") == 0) {
+ printf ("Help for <%s>\n\n", argv[0]);
+ printf (hooks_help);
+ return 0;
}
fprintf (stderr,