1 Return-Path: <bremner@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 olra.theworths.org (Postfix) with ESMTP id 5D181429E27
\r
6 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 17:15:54 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 02hxuyNPe0xe for <notmuch@notmuchmail.org>;
\r
16 Wed, 30 Nov 2011 17:15:53 -0800 (PST)
\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id AA7ED431FD0
\r
21 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 17:15:53 -0800 (PST)
\r
22 Received: from rocinante.cs.unb.ca (m3.kereda.com [207.194.238.3] (may be
\r
23 forged)) (authenticated bits=0)
\r
24 by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB11FnmK008709
\r
25 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
\r
26 Wed, 30 Nov 2011 21:15:50 -0400
\r
27 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.76)
\r
28 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
29 id 1RVvFd-0006qU-9e; Wed, 30 Nov 2011 17:15:49 -0800
\r
30 From: David Bremner <bremner@debian.org>
\r
31 To: notmuch@notmuchmail.org
\r
32 Subject: [PATCH 2/3] notmuch-dump: convert to notmuch-opts option-parsing.
\r
33 Date: Wed, 30 Nov 2011 17:15:29 -0800
\r
34 Message-Id: <1322702130-26068-2-git-send-email-bremner@debian.org>
\r
35 X-Mailer: git-send-email 1.7.5.4
\r
36 In-Reply-To: <1322702130-26068-1-git-send-email-bremner@debian.org>
\r
38 <7574621578db9bbfc88348c87e2f5431f4cb2296.1321223343.git.jani@nikula.org>
\r
39 <1322702130-26068-1-git-send-email-bremner@debian.org>
\r
40 Cc: David Bremner <bremner@debian.org>
\r
41 X-BeenThere: notmuch@notmuchmail.org
\r
42 X-Mailman-Version: 2.1.13
\r
44 List-Id: "Use and development of the notmuch mail system."
\r
45 <notmuch.notmuchmail.org>
\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
49 List-Post: <mailto:notmuch@notmuchmail.org>
\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
53 X-List-Received-Date: Thu, 01 Dec 2011 01:15:54 -0000
\r
55 This is actually a bit of a tricky case because of the treating of the
\r
56 first non-option as a filename. On the other hand, we don't do any
\r
57 "normal" argument parsing yet.
\r
59 notmuch-dump.c | 46 +++++++++++++++++++++++++++++++---------------
\r
60 1 files changed, 31 insertions(+), 15 deletions(-)
\r
62 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
63 index 0475eb9..8a8d6ec 100644
\r
64 --- a/notmuch-dump.c
\r
65 +++ b/notmuch-dump.c
\r
69 #include "notmuch-client.h"
\r
70 +#include "notmuch-opts.h"
\r
73 notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
74 @@ -41,27 +42,42 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
75 if (notmuch == NULL)
\r
78 - argc--; argv++; /* skip subcommand argument */
\r
79 + notmuch_opt_desc_t options[] = {
\r
83 - if (argc && strcmp (argv[0], "--") != 0) {
\r
84 - fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");
\r
85 - output = fopen (argv[0], "w");
\r
86 - if (output == NULL) {
\r
87 - fprintf (stderr, "Error opening %s for writing: %s\n",
\r
88 - argv[0], strerror (errno));
\r
89 + notmuch_opt_t result;
\r
91 + notmuch_bool_t more_args=TRUE;
\r
93 + for (opt_index = 1; more_args && opt_index < argc; opt_index++) {
\r
95 + more_args=parse_argument (argv[0], argv[opt_index], options, &result);
\r
97 + switch (result.arg_id) {
\r
102 + fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");
\r
103 + output = fopen (result.string, "w");
\r
104 + if (output == NULL) {
\r
105 + fprintf (stderr, "Error opening %s for writing: %s\n",
\r
106 + result.string, strerror (errno));
\r
110 + /* fall through */
\r
118 - if (argc && strcmp (argv[0], "--") == 0){
\r
122 + if (opt_index < argc && strcmp(argv[opt_index],"--") == 0)
\r
126 - query_str = query_string_from_args (notmuch, argc, argv);
\r
127 + if (opt_index < argc) {
\r
128 + query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);
\r
129 if (query_str == NULL) {
\r
130 fprintf (stderr, "Out of memory.\n");
\r