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 ED93D431FC0 for ; Sat, 22 Mar 2014 06:07:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 SmUKr+gsOGpF for ; Sat, 22 Mar 2014 06:07:04 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 3203B431FBC for ; Sat, 22 Mar 2014 06:07:04 -0700 (PDT) Received: by mail-la0-f48.google.com with SMTP id gf5so2447959lab.35 for ; Sat, 22 Mar 2014 06:07:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NDk1WekWTEbvd4u0kvdCwekVPVeDvt3wQJVAiRVHUAc=; b=b+qJx2t+r45Ht1zPlFPw70bXDv4cGr1zyEzYlYieWvTlMrooetfAMAjit7hM5UV3dx zJL+fInTAPwa6BJlEOzYNAXO/Parlwwq+ZsS8p/j6Tec5keBlp+rSakB3H1Rurbe7804 U+Drf166d8Ty/bjxTnOPjzCYd3iB6eBPu5q8q10+hqGtjZsS7V+jDtylUoN63t8vJQtK fb5Q0BSE7BAzoCpn7PjDGg+lSjqLVFScP5jFkL0ODvL8EFuv/bY0XdjbiPdCJ/c5Naqx 4++PS7RFu1bGev2ePciANJZ4ubpSuUtv95wI4ujugA2T/nBm9wQl5ZDV3cckGh1dwx7M TrNQ== X-Gm-Message-State: ALoCoQluvm0YVlcms9cqZcy+Wk8Fft8FksocQr/DVcowvb05KzGaL6VZhtj97Og3gEtwglhxBINt X-Received: by 10.112.47.3 with SMTP id z3mr1543737lbm.34.1395493621302; Sat, 22 Mar 2014 06:07:01 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id z10sm5383516lbu.1.2014.03.22.06.06.59 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 22 Mar 2014 06:07:00 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH] cli: fix notmuch help additional topics Date: Sat, 22 Mar 2014 15:06:58 +0200 Message-Id: <1395493618-29168-1-git-send-email-jani@nikula.org> X-Mailer: git-send-email 1.9.0 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:07:10 -0000 The help for hooks was missing. --- 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