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 0A17B431FAE
\r
6 for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 13:55:21 -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 nZT72VodYyjM for <notmuch@notmuchmail.org>;
\r
17 Sun, 3 Mar 2013 13:55:20 -0800 (PST)
\r
18 Received: from mail-la0-f41.google.com (mail-la0-f41.google.com
\r
19 [209.85.215.41]) (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 4A2EE431FBC
\r
22 for <notmuch@notmuchmail.org>; Sun, 3 Mar 2013 13:55:20 -0800 (PST)
\r
23 Received: by mail-la0-f41.google.com with SMTP id fo12so4440461lab.28
\r
24 for <notmuch@notmuchmail.org>; Sun, 03 Mar 2013 13:55:18 -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:cc:subject:date:message-id:x-mailer:in-reply-to
\r
28 :references:in-reply-to:references:x-gm-message-state;
\r
29 bh=wGaRPvaCRQlvxW/J5c/9raIR6+TSLjAW/ASXq6YhIGs=;
\r
30 b=UZODMkm+nIiTl39U+4higi3rVQXoeQsNINxP9ATfR80argyOgHqlyA05ZiMXtEKTSi
\r
31 PLu7NLi+C6usYILNz1QtmvfN/VXpkduDsxJfc5UGX4Ks50qOMEu1zbrJq4g0CaGqSLuZ
\r
32 BiCIh+/zh5uex3zkhVFKOVRDlLmZptKzQyxOjZFiysLu1OT71RvfMo6HmBSqkkidWOA2
\r
33 8cfjUNIDm4viyxhB572Kb6u23gUWEIT7csZs7dIiYoqlQBpAwNvosqolgOENha+Tkb15
\r
34 S9daB3Had8Fw+yv5KSykMsjMO6CTefrNozK0pz1nKxA1/Vlk8iPm/oh5/AIFo3Azai2B
\r
36 X-Received: by 10.152.125.239 with SMTP id mt15mr15873485lab.26.1362347718747;
\r
37 Sun, 03 Mar 2013 13:55:18 -0800 (PST)
\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPS id b13sm6611855lbd.10.2013.03.03.13.55.17
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Sun, 03 Mar 2013 13:55:17 -0800 (PST)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [PATCH v2 2/6] cli: plug main notmuch command into subcommand
\r
47 Date: Sun, 3 Mar 2013 23:55:06 +0200
\r
49 <bf81d217ceefc512a252a5acccd3c62b185eb874.1362347362.git.jani@nikula.org>
\r
50 X-Mailer: git-send-email 1.7.10.4
\r
51 In-Reply-To: <cover.1362347362.git.jani@nikula.org>
\r
52 References: <cover.1362347362.git.jani@nikula.org>
\r
53 In-Reply-To: <cover.1362347362.git.jani@nikula.org>
\r
54 References: <cover.1362347362.git.jani@nikula.org>
\r
56 ALoCoQmq3hzDQCOlvErbDQfgVMIA29Zu//QKRxYDVL0CdCdTCcUKgQFoeWrpZQAOxd6wC5ok2OoI
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Sun, 03 Mar 2013 21:55:21 -0000
\r
71 This allows top level arguments to be added to notmuch in a way that
\r
72 doesn't require special handling for the plain notmuch command without
\r
75 notmuch.c | 26 +++++++++++++++++---------
\r
76 1 file changed, 17 insertions(+), 9 deletions(-)
\r
78 diff --git a/notmuch.c b/notmuch.c
\r
79 index 3dff6d4..ec2f20f 100644
\r
82 @@ -34,7 +34,13 @@ typedef struct command {
\r
84 notmuch_help_command (void *ctx, int argc, char *argv[]);
\r
87 +notmuch_command (void *ctx, int argc, char *argv[]);
\r
89 static command_t commands[] = {
\r
90 + { NULL, notmuch_command,
\r
92 + "Notmuch main command." },
\r
93 { "setup", notmuch_setup_command,
\r
95 "Interactively setup notmuch for first use." },
\r
96 @@ -76,7 +82,8 @@ find_command (const char *name)
\r
99 for (i = 0; i < ARRAY_SIZE (commands); i++)
\r
100 - if (strcmp (name, commands[i].name) == 0)
\r
101 + if ((!name && !commands[i].name) ||
\r
102 + (name && commands[i].name && strcmp (name, commands[i].name) == 0))
\r
103 return &commands[i];
\r
106 @@ -101,8 +108,8 @@ usage (FILE *out)
\r
107 for (i = 0; i < ARRAY_SIZE (commands); i++) {
\r
108 command = &commands[i];
\r
110 - fprintf (out, " %-11s %s\n",
\r
111 - command->name, command->summary);
\r
112 + if (command->name)
\r
113 + fprintf (out, " %-11s %s\n", command->name, command->summary);
\r
116 fprintf (out, "\n");
\r
117 @@ -192,7 +199,7 @@ notmuch_help_command (void *ctx, int argc, char *argv[])
\r
118 * to be more clever about this in the future.
\r
121 -notmuch (void *ctx)
\r
122 +notmuch_command (void *ctx, unused(int argc), unused(char *argv[]))
\r
124 notmuch_config_t *config;
\r
125 notmuch_bool_t is_new;
\r
126 @@ -256,6 +263,7 @@ main (int argc, char *argv[])
\r
129 char *talloc_report;
\r
130 + const char *command_name = NULL;
\r
131 command_t *command;
\r
132 notmuch_bool_t print_help=FALSE, print_version=FALSE;
\r
134 @@ -277,9 +285,6 @@ main (int argc, char *argv[])
\r
135 /* Globally default to the current output format version. */
\r
136 notmuch_format_version = NOTMUCH_FORMAT_CUR;
\r
139 - return notmuch (local);
\r
141 opt_index = parse_arguments (argc, argv, options, 1);
\r
142 if (opt_index < 0) {
\r
143 /* diagnostics already printed */
\r
144 @@ -294,10 +299,13 @@ main (int argc, char *argv[])
\r
148 - command = find_command (argv[opt_index]);
\r
149 + if (opt_index < argc)
\r
150 + command_name = argv[opt_index];
\r
152 + command = find_command (command_name);
\r
154 fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
\r
155 - argv[opt_index]);
\r