Re: Avoiding the "huge INBOX of death"
[notmuch-archives.git] / 87 / 67e5c01b3ea76063fb4c946e9a28934bc7c98a
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 25EE1429E41\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 11:26:54 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \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 tIX7NnNKh+Gk for <notmuch@notmuchmail.org>;\r
16         Wed,  7 Dec 2011 11:26: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 AC5FF429E32\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 pB7JQhpx021340;\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-0004Pm-Tj; 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 3/5] notmuch-dump: convert to command-line-arguments\r
31 Date: Wed,  7 Dec 2011 15:26:37 -0400\r
32 Message-Id: <1323285999-16870-4-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
40 Precedence: list\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:54 -0000\r
51 \r
52 From: David Bremner <bremner@debian.org>\r
53 \r
54 The output file is handled via positional arguments. There are\r
55 currently no "normal" options.\r
56 ---\r
57  notmuch-dump.c |   31 +++++++++++++++++++------------\r
58  1 files changed, 19 insertions(+), 12 deletions(-)\r
59 \r
60 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
61 index a490917..a735875 100644\r
62 --- a/notmuch-dump.c\r
63 +++ b/notmuch-dump.c\r
64 @@ -41,27 +41,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
65      if (notmuch == NULL)\r
66         return 1;\r
67  \r
68 -    argc--; argv++; /* skip subcommand argument */\r
69 +    char *output_file_name = NULL;\r
70 +    int opt_index;\r
71  \r
72 -    if (argc && strcmp (argv[0], "--") != 0) {\r
73 +    notmuch_opt_desc_t options[] = {\r
74 +       { NOTMUCH_OPT_POSITION, &output_file_name, 0, 0, 0  },\r
75 +       { 0, 0, 0, 0, 0 }\r
76 +    };\r
77 +\r
78 +    opt_index = parse_arguments (argc, argv, options, 1);\r
79 +\r
80 +    if (opt_index < 0) {\r
81 +       /* diagnostics already printed */\r
82 +       return 1;\r
83 +    }\r
84 +\r
85 +    if (output_file_name) {\r
86         fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
87 -       output = fopen (argv[0], "w");\r
88 +       output = fopen (output_file_name, "w");\r
89         if (output == NULL) {\r
90             fprintf (stderr, "Error opening %s for writing: %s\n",\r
91 -                    argv[0], strerror (errno));\r
92 +                    output_file_name, strerror (errno));\r
93             return 1;\r
94         }\r
95 -       argc--;\r
96 -       argv++;\r
97      }\r
98  \r
99 -    if (argc && strcmp (argv[0], "--") == 0){\r
100 -       argc--;\r
101 -       argv++;\r
102 -    }\r
103  \r
104 -    if (argc) {\r
105 -       query_str = query_string_from_args (notmuch, argc, argv);\r
106 +    if (opt_index < argc) {\r
107 +       query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);\r
108         if (query_str == NULL) {\r
109             fprintf (stderr, "Out of memory.\n");\r
110             return 1;\r
111 -- \r
112 1.7.5.4\r
113 \r