Re: Xapian-quoting based batch-tagging.
[notmuch-archives.git] / 78 / 977922b70415aabcfe0d4200439161422f49f3
1 Return-Path: <bremner@tethera.net>\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 752AE431FD0\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 04:34:59 -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 DV1ior2gkt+6 for <notmuch@notmuchmail.org>;\r
16         Wed,  7 Dec 2011 04:34:58 -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 850D2429E30\r
21         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 04:34:57 -0800 (PST)\r
22 Received: from zancas.localnet\r
23         (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
24         [156.34.79.193]) (authenticated bits=0)\r
25         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB7CYqVf007120\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Wed, 7 Dec 2011 08:34:53 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.77)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RYGi4-0007mw-KR; Wed, 07 Dec 2011 08:34:52 -0400\r
31 From: David Bremner <david@tethera.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH 2/4] notmuch-dump: convert to command-line-arguments\r
34 Date: Wed,  7 Dec 2011 08:34:38 -0400\r
35 Message-Id: <1323261280-29907-2-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.7.3\r
37 In-Reply-To: <1323261280-29907-1-git-send-email-david@tethera.net>\r
38 References: <87iplso9c9.fsf@zancas.localnet>\r
39         <1323261280-29907-1-git-send-email-david@tethera.net>\r
40 Cc: David Bremner <bremner@debian.org>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\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: Wed, 07 Dec 2011 12:34:59 -0000\r
54 \r
55 From: David Bremner <bremner@debian.org>\r
56 \r
57 The output file is handled via positional arguments. There are\r
58 currently no "normal" options.\r
59 ---\r
60  notmuch-dump.c |   31 +++++++++++++++++++------------\r
61  1 files changed, 19 insertions(+), 12 deletions(-)\r
62 \r
63 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
64 index a490917..c568734 100644\r
65 --- a/notmuch-dump.c\r
66 +++ b/notmuch-dump.c\r
67 @@ -41,27 +41,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
68      if (notmuch == NULL)\r
69         return 1;\r
70  \r
71 -    argc--; argv++; /* skip subcommand argument */\r
72 +    char *output_file_name = NULL;\r
73 +    int opt_index;\r
74  \r
75 -    if (argc && strcmp (argv[0], "--") != 0) {\r
76 +    notmuch_opt_desc_t options[] = {\r
77 +       { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },\r
78 +       { 0, 0, 0, 0, 0 }\r
79 +    };\r
80 +\r
81 +    opt_index = parse_arguments (argc, argv, options, 1);\r
82 +\r
83 +    if (opt_index < 0) {\r
84 +       /* diagnostics already printed */\r
85 +       exit(1);\r
86 +    }\r
87 +\r
88 +    if (output_file_name) {\r
89         fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
90 -       output = fopen (argv[0], "w");\r
91 +       output = fopen (output_file_name, "w");\r
92         if (output == NULL) {\r
93             fprintf (stderr, "Error opening %s for writing: %s\n",\r
94 -                    argv[0], strerror (errno));\r
95 +                    output_file_name, strerror (errno));\r
96             return 1;\r
97         }\r
98 -       argc--;\r
99 -       argv++;\r
100      }\r
101  \r
102 -    if (argc && strcmp (argv[0], "--") == 0){\r
103 -       argc--;\r
104 -       argv++;\r
105 -    }\r
106  \r
107 -    if (argc) {\r
108 -       query_str = query_string_from_args (notmuch, argc, argv);\r
109 +    if (opt_index < argc) {\r
110 +       query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);\r
111         if (query_str == NULL) {\r
112             fprintf (stderr, "Out of memory.\n");\r
113             return 1;\r
114 -- \r
115 1.7.7.3\r
116 \r