X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=0fac0997865e6acd8622707c49d2d29999d488e3;hp=2d7f33d3d8d69c0c9418f57c428bd78c0b7f27ec;hb=9d19f325f5a0879e2f646e83e59595d5cb345de3;hpb=c7453773064efbd0b2cd17b15ba483edbd28ce1e diff --git a/notmuch.c b/notmuch.c index 2d7f33d3..0fac0997 100644 --- a/notmuch.c +++ b/notmuch.c @@ -54,6 +54,8 @@ static command_t commands[] = { "Add a new message into the maildir and notmuch database." }, { "search", notmuch_search_command, FALSE, "Search for messages matching the given search terms." }, + { "address", notmuch_address_command, FALSE, + "Get addresses from messages matching the given search terms." }, { "show", notmuch_show_command, FALSE, "Show all messages matching the search terms." }, { "count", notmuch_count_command, FALSE, @@ -74,6 +76,18 @@ static command_t commands[] = { "This message, or more detailed help for the named command." } }; +typedef struct help_topic { + const char *name; + const char *summary; +} help_topic_t; + +static help_topic_t help_topics[] = { + { "search-terms", + "Common search term syntax." }, + { "hooks", + "Hooks that will be run before or after certain commands." }, +}; + static command_t * find_command (const char *name) { @@ -93,6 +107,7 @@ static void usage (FILE *out) { command_t *command; + help_topic_t *topic; unsigned int i; fprintf (out, @@ -107,13 +122,22 @@ usage (FILE *out) command = &commands[i]; if (command->name) - fprintf (out, " %-11s %s\n", command->name, command->summary); + fprintf (out, " %-12s %s\n", command->name, command->summary); + } + + fprintf (out, "\n"); + fprintf (out, "Additional help topics are as follows:\n"); + fprintf (out, "\n"); + + for (i = 0; i < ARRAY_SIZE (help_topics); i++) { + topic = &help_topics[i]; + fprintf (out, " %-12s %s\n", topic->name, topic->summary); } fprintf (out, "\n"); fprintf (out, - "Use \"notmuch help \" for more details on each command\n" - "and \"notmuch help search-terms\" for the common search-terms syntax.\n\n"); + "Use \"notmuch help \" for more details " + "on each command or topic.\n\n"); } void @@ -156,6 +180,8 @@ static int notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]) { command_t *command; + help_topic_t *topic; + unsigned int i; argc--; argv++; /* Ignore "help" */ @@ -180,10 +206,12 @@ notmuch_help_command (notmuch_config_t *config, int argc, char *argv[]) exec_man (page); } - if (strcmp (argv[0], "search-terms") == 0) { - exec_man ("notmuch-search-terms"); - } else if (strcmp (argv[0], "hooks") == 0) { - exec_man ("notmuch-hooks"); + for (i = 0; i < ARRAY_SIZE (help_topics); i++) { + topic = &help_topics[i]; + if (strcmp (argv[0], topic->name) == 0) { + char *page = talloc_asprintf (config, "notmuch-%s", topic->name); + exec_man (page); + } } fprintf (stderr, @@ -256,7 +284,7 @@ main (int argc, char *argv[]) const char *command_name = NULL; command_t *command; char *config_file_name = NULL; - notmuch_config_t *config; + notmuch_config_t *config = NULL; notmuch_bool_t print_help=FALSE, print_version=FALSE; int opt_index; int ret; @@ -316,7 +344,9 @@ main (int argc, char *argv[]) ret = (command->function)(config, argc - opt_index, argv + opt_index); - notmuch_config_close (config); + DONE: + if (config) + notmuch_config_close (config); talloc_report = getenv ("NOTMUCH_TALLOC_REPORT"); if (talloc_report && strcmp (talloc_report, "") != 0) { @@ -334,7 +364,6 @@ main (int argc, char *argv[]) } } - DONE: talloc_free (local); return ret;