1 Return-Path: <bremner@pivot.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 olra.theworths.org (Postfix) with ESMTP id D7208429E2F
\r
6 for <notmuch@notmuchmail.org>; Wed, 7 Dec 2011 11:26:55 -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 edrw6pvPP8sx for <notmuch@notmuchmail.org>;
\r
16 Wed, 7 Dec 2011 11:26:54 -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 ED73F429E37
\r
21 for <notmuch@notmuchmail.org>; Wed, 7 Dec 2011 11:26:49 -0800 (PST)
\r
22 Received: from convex-new.cs.unb.ca ([131.202.13.154])
\r
23 by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB7JQhNn021341;
\r
24 Wed, 7 Dec 2011 15:26:46 -0400
\r
25 Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72)
\r
26 (envelope-from <bremner@pivot.cs.unb.ca>)
\r
27 id 1RYN8d-0004Pp-UW; Wed, 07 Dec 2011 15:26:43 -0400
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Subject: [PATCH v4 4/5] notmuch-restore: convert to command-line-arguments
\r
31 Date: Wed, 7 Dec 2011 15:26:38 -0400
\r
32 Message-Id: <1323285999-16870-5-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 1.7.5.4
\r
34 In-Reply-To: <1323285999-16870-1-git-send-email-david@tethera.net>
\r
35 References: <87iplso9c9.fsf@zancas.localnet>
\r
36 <1323285999-16870-1-git-send-email-david@tethera.net>
\r
37 Cc: David Bremner <bremner@debian.org>
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Wed, 07 Dec 2011 19:26:56 -0000
\r
52 From: David Bremner <bremner@debian.org>
\r
54 The new argument handling is a bit more concise, and bit more
\r
55 flexible. It allows the input file name to go before the --accumulate
\r
58 notmuch-restore.c | 37 +++++++++++++++----------------------
\r
59 1 files changed, 15 insertions(+), 22 deletions(-)
\r
61 diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
62 index 13b4325..87d9772 100644
\r
63 --- a/notmuch-restore.c
\r
64 +++ b/notmuch-restore.c
\r
66 * Author: Carl Worth <cworth@cworth.org>
\r
69 -#include <getopt.h>
\r
71 #include "notmuch-client.h"
\r
74 @@ -29,12 +27,14 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
75 notmuch_database_t *notmuch;
\r
76 notmuch_bool_t synchronize_flags;
\r
77 notmuch_bool_t accumulate = FALSE;
\r
78 + char *input_file_name = NULL;
\r
79 FILE *input = stdin;
\r
87 config = notmuch_config_open (ctx, NULL, NULL);
\r
89 @@ -47,37 +47,30 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
91 synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
\r
93 - struct option options[] = {
\r
94 - { "accumulate", no_argument, 0, 'a' },
\r
96 + notmuch_opt_desc_t options[] = {
\r
97 + { NOTMUCH_OPT_POSITION, &input_file_name, 0, 0, 0 },
\r
98 + { NOTMUCH_OPT_BOOLEAN, &accumulate, "accumulate", 'a', 0 },
\r
104 - opt = getopt_long (argc, argv, "", options, NULL);
\r
114 + opt_index = parse_arguments (argc, argv, options, 1);
\r
116 - } while (opt != -1);
\r
117 + if (opt_index < 0) {
\r
118 + /* diagnostics already printed */
\r
122 - if (optind < argc) {
\r
123 - input = fopen (argv[optind], "r");
\r
124 + if (input_file_name) {
\r
125 + input = fopen (input_file_name, "r");
\r
126 if (input == NULL) {
\r
127 fprintf (stderr, "Error opening %s for reading: %s\n",
\r
128 - argv[optind], strerror (errno));
\r
129 + input_file_name, strerror (errno));
\r
135 - if (optind < argc) {
\r
136 + if (opt_index < argc) {
\r
138 "Cannot read dump from more than one file: %s\n",
\r