]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.c
cli: fix use of uninitialized variable in "notmuch reply"
[notmuch] / notmuch.c
index 9bb884712dbb86a6dc245219f2d4495dc3faf464..c0ce026a14ff904d29fbf53ca53b40975855bf52 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -32,7 +32,7 @@ typedef struct command {
     const char *documentation;
 } command_t;
 
-#define MAX_ALIAS_SUBSTITUTIONS 2
+#define MAX_ALIAS_SUBSTITUTIONS 3
 
 typedef struct alias {
     const char *name;
@@ -40,14 +40,15 @@ typedef struct alias {
 } alias_t;
 
 alias_t aliases[] = {
-    { "part", { "show", "--format=raw"}}
+    { "part", { "show", "--format=raw"}},
+    { "search-tags", {"search", "--output=tags", "*"}}
 };
 
 static int
 notmuch_help_command (void *ctx, int argc, char *argv[]);
 
 static const char search_terms_help[] =
-    "\tSeveral notmuch commands accept a comman syntax for search\n"
+    "\tSeveral notmuch commands accept a common syntax for search\n"
     "\tterms.\n"
     "\n"
     "\tThe search terms can consist of free-form text (and quoted\n"
@@ -126,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,
@@ -143,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"
@@ -158,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"
@@ -221,6 +255,15 @@ static command_t commands[] = {
       "\t\t(oldest-first) or reverse chronological order\n"
       "\t\t(newest-first), which is the default.\n"
       "\n"
+      "\t--offset=[-]N\n"
+      "\n"
+      "\t\tSkip displaying the first N results. With the leading '-',\n"
+      "\t\tstart at the Nth result from the end.\n"
+      "\n"
+      "\t--limit=N\n"
+      "\n"
+      "\t\tLimit the number of displayed results to N.\n"
+      "\n"
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
     { "show", notmuch_show_command,
@@ -293,6 +336,22 @@ static command_t commands[] = {
       "\t\tmessage MIME structure, and are identified in the 'json' or\n"
       "\t\t'text' output formats.\n"
       "\n"
+      "\t--verify\n"
+      "\n"
+      "\t\tCompute and report the validity of any MIME cryptographic\n"
+      "\t\tsignatures found in the selected content (ie.\n"
+      "\t\t\"multipart/signed\" parts). Status of the signature will be\n"
+      "\t\treported (currently only supported with --format=json) and\n"
+      "\t\tthe multipart/signed part will be replaced by the signed data.\n"
+      "\n"
+      "\t--decrypt\n"
+      "\n"
+      "\t\tDecrypt any MIME encrypted parts found in the selected content\n"
+      "\t\t(ie. \"multipart/encrypted\" parts). Status of the decryption\n"
+      "\t\twill be reported (currently only supported with --format=json)\n"
+      "\t\tand the multipart/encrypted part will be replaced by the\n"
+      "\t\tdecrypted content.\n"
+      "\n"
       "\n"
       "\tA common use of \"notmuch show\" is to display a single\n"
       "\tthread of email messages. For this, use a search term of\n"
@@ -302,12 +361,24 @@ static command_t commands[] = {
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
     { "count", notmuch_count_command,
-      "<search-terms> [...]",
+      "[options...] <search-terms> [...]",
       "Count messages matching the search terms.",
-      "\tThe number of matching messages is output to stdout.\n"
+      "\tThe number of matching messages (or threads) is output to stdout.\n"
+      "\n"
+      "\tWith no search terms, a count of all messages (or threads) in\n"
+      "\tthe database will be displayed.\n"
+      "\n"
+      "\tSupported options for count include:\n"
+      "\n"
+      "\t--output=(messages|threads)\n"
+      "\n"
+      "\t\tmessages (default)\n"
+      "\n"
+      "\t\tOutput the number of matching messages.\n"
       "\n"
-      "\tWith no search terms, a count of all messages in the database\n"
-      "\twill be displayed.\n"
+      "\t\tthreads\n"
+      "\n"
+      "\t\tOutput the number of matching threads.\n"
       "\n"
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
@@ -358,31 +429,35 @@ static command_t commands[] = {
       "\tSee \"notmuch help search-terms\" for details of the search\n"
       "\tterms syntax." },
     { "dump", notmuch_dump_command,
-      "[<filename>]",
+      "[<filename>] [--] [<search-terms>]",
       "Create a plain-text dump of the tags for each message.",
       "\tOutput is to the given filename, if any, or to stdout.\n"
+      "\tNote that using the filename argument is deprecated.\n"
+      "\n"
       "\tThese tags are the only data in the notmuch database\n"
       "\tthat can't be recreated from the messages themselves.\n"
       "\tThe output of notmuch dump is therefore the only\n"
       "\tcritical thing to backup (and much more friendly to\n"
-      "\tincremental backup than the native database files.)" },
+      "\tincremental backup than the native database files.)\n" 
+      "\n"
+      "\tWith no search terms, a dump of all messages in the\n"
+      "\tdatabase will be generated. A \"--\" argument instructs\n"
+      "\tnotmuch that the remaining arguments are search terms.\n"
+      "\n"
+      "\tSee \"notmuch help search-terms\" for the search-term syntax.\n"      
+ },
     { "restore", notmuch_restore_command,
-      "<filename>",
+      "[--accumulate] [<filename>]",
       "Restore the tags from the given dump file (see 'dump').",
+      "\tInput is read from the given filename, if any, or from stdin.\n"
       "\tNote: The dump file format is specifically chosen to be\n"
       "\tcompatible with the format of files produced by sup-dump.\n"
       "\tSo if you've previously been using sup for mail, then the\n"
       "\t\"notmuch restore\" command provides you a way to import\n"
-      "\tall of your tags (or labels as sup calls them)." },
-    { "search-tags", notmuch_search_tags_command,
-      "[<search-terms> [...] ]",
-      "List all tags found in the database or matching messages.",
-      "\tRun this command without any search-term(s) to obtain a list\n"
-      "\tof all tags found in the database. If you provide one or more\n"
-      "\tsearch-terms as argument(s) then the resulting list will\n"
-      "\tcontain tags only from messages that match the search-term(s).\n"
-      "\n"
-      "\tIn both cases the list will be alphabetically sorted." },
+      "\tall of your tags (or labels as sup calls them).\n"
+      "\tThe --accumulate switch causes the union of the existing and new\n"
+      "\ttags to be applied, instead of replacing each message's tags as\n"
+      "\tthey are read in from the dump file."},
     { "config", notmuch_config_command,
       "[get|set] <section>.<item> [value ...]",
       "Get or set settings in the notmuch configuration file.",
@@ -448,6 +523,8 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])
     command_t *command;
     unsigned int i;
 
+    argc--; argv++; /* Ignore "help" */
+
     if (argc == 0) {
        printf ("The notmuch mail system.\n\n");
        usage (stdout);
@@ -485,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,
@@ -571,12 +652,13 @@ main (int argc, char *argv[])
     local = talloc_new (NULL);
 
     g_mime_init (0);
+    g_type_init ();
 
     if (argc == 1)
        return notmuch (local);
 
     if (STRNCMP_LITERAL (argv[1], "--help") == 0)
-       return notmuch_help_command (NULL, 0, NULL);
+       return notmuch_help_command (NULL, argc - 1, &argv[1]);
 
     if (STRNCMP_LITERAL (argv[1], "--version") == 0) {
        printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n");
@@ -621,7 +703,7 @@ main (int argc, char *argv[])
        command = &commands[i];
 
        if (strcmp (argv[1], command->name) == 0)
-           return (command->function) (local, argc - 2, &argv[2]);
+           return (command->function) (local, argc - 1, &argv[1]);
     }
 
     fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",