From: Tomi Ollila Date: Sat, 22 Mar 2014 13:17:53 +0000 (+0200) Subject: Re: [PATCH] cli: fix notmuch help additional topics X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2dcbe6662a8eeab75ed9fc700fcdc7f1abee2f64;p=notmuch-archives.git Re: [PATCH] cli: fix notmuch help additional topics --- diff --git a/1b/57f0e8894102543201216576ba5d9a2447bd12 b/1b/57f0e8894102543201216576ba5d9a2447bd12 new file mode 100644 index 000000000..1032aa146 --- /dev/null +++ b/1b/57f0e8894102543201216576ba5d9a2447bd12 @@ -0,0 +1,153 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 92A2B431FC0 + for ; Sat, 22 Mar 2014 06:18:10 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 9Fw5QPEFoyx0 for ; + Sat, 22 Mar 2014 06:18:03 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 93ACA431FBC + for ; Sat, 22 Mar 2014 06:18:03 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 9AC1E100033; + Sat, 22 Mar 2014 15:17:53 +0200 (EET) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH] cli: fix notmuch help additional topics +In-Reply-To: <1395493618-29168-1-git-send-email-jani@nikula.org> +References: <1395493618-29168-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.17+155~g3416ef5 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 22 Mar 2014 13:18:10 -0000 + +On Sat, Mar 22 2014, Jani Nikula wrote: + +> The help for hooks was missing. +> +> --- + +The code changes LGTM. + +Tomi + +> notmuch.c | 40 +++++++++++++++++++++++++++++++++------- +> 1 file changed, 33 insertions(+), 7 deletions(-) +> +> diff --git a/notmuch.c b/notmuch.c +> index b3fa9f378545..dcda0392a094 100644 +> --- a/notmuch.c +> +++ b/notmuch.c +> @@ -74,6 +74,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 +105,7 @@ static void +> usage (FILE *out) +> { +> command_t *command; +> + help_topic_t *topic; +> unsigned int i; +> +> fprintf (out, +> @@ -107,13 +120,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 +178,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 +204,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, +> -- +> 1.9.0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch