1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id CD430431FAE
\r
6 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:47:02 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id wt6ZMJb2I2ze for <notmuch@notmuchmail.org>;
\r
17 Tue, 29 Jan 2013 13:47:01 -0800 (PST)
\r
18 Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com
\r
19 [209.85.217.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 2417E431FDB
\r
22 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:55 -0800 (PST)
\r
23 Received: by mail-lb0-f182.google.com with SMTP id gg6so1345585lbb.13
\r
24 for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:53 -0800 (PST)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=google.com; s=20120113;
\r
27 h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to
\r
28 :references:in-reply-to:references:x-gm-message-state;
\r
29 bh=uhL2LZNjBb0n5brjrnx0H08GMZdz6QacbnD+fdoOBbU=;
\r
30 b=PSJpy3JNUhG0gHW8R1k17ZWT8bH57Bq5X/Jf1UrRr/bG2F+63cS56EDwydW6WhTJ1m
\r
31 /9n9lucxEZkQuq5rkOvi8a9MM//nXelqtfDyHedwcGIrHSzv8U/9fVSa0UjF+kC/npLc
\r
32 hFujV7nzJHNVuXLamws9PEX1MkK3JzR1OaAbUwCXQs8/CJm5FTmeh79/KhT56gRYRmlZ
\r
33 h+DokuZ/euMBlykOQ6Q1oQ8p7Fq6vgL+o7NUcNCe0xMt2zmnhpAzld9fqSn6uofdF+Fo
\r
34 //2QbppDfNHSGLLznKnTUr9xDl90jvtQn142dLgKJPahv5W19xt6Ojsjf7lNiSM4WPe3
\r
36 X-Received: by 10.112.48.130 with SMTP id l2mr1036206lbn.44.1359496013145;
\r
37 Tue, 29 Jan 2013 13:46:53 -0800 (PST)
\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id f8sm5597960lbg.2.2013.01.29.13.46.50
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Tue, 29 Jan 2013 13:46:52 -0800 (PST)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH 4/6] cli: plug main notmuch command into subcommand machinery
\r
46 Date: Tue, 29 Jan 2013 23:46:22 +0200
\r
48 <c1afb811a526ec08331af75d12d5edfd01bf9279.1359495450.git.jani@nikula.org>
\r
49 X-Mailer: git-send-email 1.7.10.4
\r
50 In-Reply-To: <cover.1359495450.git.jani@nikula.org>
\r
51 References: <cover.1359495450.git.jani@nikula.org>
\r
52 In-Reply-To: <cover.1359495450.git.jani@nikula.org>
\r
53 References: <cover.1359495450.git.jani@nikula.org>
\r
55 ALoCoQmgBoKO3ZmBScS0a/lkLZAVeqS4wAASF/THun6FW89UYUqbwe/jp9XQV71Zu30zsCtkeG/O
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Tue, 29 Jan 2013 21:47:03 -0000
\r
70 This also allows the main notmuch command to have arguments (though
\r
73 notmuch.c | 26 +++++++++++++++++---------
\r
74 1 file changed, 17 insertions(+), 9 deletions(-)
\r
76 diff --git a/notmuch.c b/notmuch.c
\r
77 index c47b998..67d5772 100644
\r
80 @@ -34,7 +34,13 @@ typedef struct command {
\r
82 notmuch_help_command (void *ctx, int argc, char *argv[]);
\r
85 +notmuch_command (void *ctx, int argc, char *argv[]);
\r
87 static command_t commands[] = {
\r
88 + { NULL, notmuch_command,
\r
90 + "Notmuch main command." },
\r
91 { "setup", notmuch_setup_command,
\r
93 "Interactively setup notmuch for first use." },
\r
94 @@ -76,7 +82,8 @@ find_command (const char *name)
\r
97 for (i = 0; i < ARRAY_SIZE (commands); i++)
\r
98 - if (strcmp (name, commands[i].name) == 0)
\r
99 + if ((!name && !commands[i].name) ||
\r
100 + (name && commands[i].name && strcmp (name, commands[i].name) == 0))
\r
101 return &commands[i];
\r
104 @@ -101,8 +108,8 @@ usage (FILE *out)
\r
105 for (i = 0; i < ARRAY_SIZE (commands); i++) {
\r
106 command = &commands[i];
\r
108 - fprintf (out, " %-11s %s\n",
\r
109 - command->name, command->summary);
\r
110 + if (command->name)
\r
111 + fprintf (out, " %-11s %s\n", command->name, command->summary);
\r
114 fprintf (out, "\n");
\r
115 @@ -192,7 +199,7 @@ notmuch_help_command (void *ctx, int argc, char *argv[])
\r
116 * to be more clever about this in the future.
\r
119 -notmuch (void *ctx)
\r
120 +notmuch_command (void *ctx, unused(int argc), unused(char *argv[]))
\r
122 notmuch_config_t *config;
\r
124 @@ -255,6 +262,7 @@ main (int argc, char *argv[])
\r
127 char *talloc_report;
\r
128 + const char *command_name = NULL;
\r
129 command_t *command;
\r
130 notmuch_bool_t print_help=FALSE, print_version=FALSE;
\r
132 @@ -276,9 +284,6 @@ main (int argc, char *argv[])
\r
133 /* Globally default to the current output format version. */
\r
134 notmuch_format_version = NOTMUCH_FORMAT_CUR;
\r
137 - return notmuch (local);
\r
139 opt_index = parse_arguments (argc, argv, options, 1);
\r
140 if (opt_index < 0) {
\r
141 /* diagnostics already printed */
\r
142 @@ -293,10 +298,13 @@ main (int argc, char *argv[])
\r
146 - command = find_command (argv[opt_index]);
\r
147 + if (opt_index < argc)
\r
148 + command_name = argv[opt_index];
\r
150 + command = find_command (command_name);
\r
152 fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
\r
153 - argv[opt_index]);
\r