1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id C81556DE1B43
\r
6 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 14:33:24 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.67 tagged_above=-999 required=5 tests=[AWL=0.660,
\r
12 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id U22E_QsMuFQl for <notmuch@notmuchmail.org>;
\r
16 Sun, 5 Apr 2015 14:33:22 -0700 (PDT)
\r
17 X-Greylist: delayed 1942 seconds by postgrey-1.35 at arlo;
\r
18 Sun, 05 Apr 2015 14:33:22 PDT
\r
19 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
21 by arlo.cworth.org (Postfix) with ESMTPS id 405A36DE1B42
\r
22 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 14:33:22 -0700 (PDT)
\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
24 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
25 id 1Yerfi-0002Ru-TG; Sun, 05 Apr 2015 21:01:34 +0000
\r
26 Received: (nullmailer pid 29562 invoked by uid 1000); Sun, 05 Apr 2015
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Subject: [PATCH 2/4] cli: refactor notmuch_help_command
\r
31 Date: Mon, 6 Apr 2015 05:59:32 +0900
\r
32 Message-Id: <1428267574-28797-3-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 2.1.4
\r
34 In-Reply-To: <1428267574-28797-1-git-send-email-david@tethera.net>
\r
35 References: <1428267574-28797-1-git-send-email-david@tethera.net>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.18
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Sun, 05 Apr 2015 21:33:24 -0000
\r
50 Create a new private entry point _help_for so that we can call help
\r
51 without simulating a command line invokation to set up the arguments.
\r
53 notmuch.c | 26 ++++++++++++++++++--------
\r
54 1 file changed, 18 insertions(+), 8 deletions(-)
\r
56 diff --git a/notmuch.c b/notmuch.c
\r
57 index 31672c3..bff941f 100644
\r
60 @@ -177,21 +177,19 @@ exec_man (const char *page)
\r
64 -notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[])
\r
65 +_help_for (const char *topic_name)
\r
68 help_topic_t *topic;
\r
71 - argc--; argv++; /* Ignore "help" */
\r
74 + if (!topic_name) {
\r
75 printf ("The notmuch mail system.\n\n");
\r
77 return EXIT_SUCCESS;
\r
80 - if (strcmp (argv[0], "help") == 0) {
\r
81 + if (strcmp (topic_name, "help") == 0) {
\r
82 printf ("The notmuch help system.\n\n"
\r
83 "\tNotmuch uses the man command to display help. In case\n"
\r
84 "\tof difficulties check that MANPATH includes the pages\n"
\r
85 @@ -200,7 +198,7 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
\r
86 return EXIT_SUCCESS;
\r
89 - command = find_command (argv[0]);
\r
90 + command = find_command (topic_name);
\r
92 char *page = talloc_asprintf (NULL, "notmuch-%s", command->name);
\r
94 @@ -208,7 +206,7 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
\r
96 for (i = 0; i < ARRAY_SIZE (help_topics); i++) {
\r
97 topic = &help_topics[i];
\r
98 - if (strcmp (argv[0], topic->name) == 0) {
\r
99 + if (strcmp (topic_name, topic->name) == 0) {
\r
100 char *page = talloc_asprintf (NULL, "notmuch-%s", topic->name);
\r
103 @@ -216,10 +214,22 @@ notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[]
\r
106 "\nSorry, %s is not a known command. There's not much I can do to help.\n\n",
\r
109 return EXIT_FAILURE;
\r
113 +notmuch_help_command (unused (notmuch_config_t * config), int argc, char *argv[])
\r
115 + argc--; argv++; /* Ignore "help" */
\r
118 + return _help_for (NULL);
\r
121 + return _help_for (argv[0]);
\r
124 /* Handle the case of "notmuch" being invoked with no command
\r
125 * argument. For now we just call notmuch_setup_command, but we plan
\r
126 * to be more clever about this in the future.
\r