Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 76 / 5c150dc8be3b165d81e5a74a6a543159661897
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 26CDA429E26\r
6         for <notmuch@notmuchmail.org>; Tue,  6 Dec 2011 12:43:44 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 eVeaDB0OvMFF for <notmuch@notmuchmail.org>;\r
16         Tue,  6 Dec 2011 12:43:43 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  64406429E21    for <notmuch@notmuchmail.org>; Tue,  6 Dec 2011 12:43:43 -0800\r
21  (PST)\r
22 Received: by wgbds13 with SMTP id ds13so5706407wgb.2\r
23         for <notmuch@notmuchmail.org>; Tue, 06 Dec 2011 12:43:42 -0800 (PST)\r
24 Received: by 10.227.203.10 with SMTP id fg10mr12462465wbb.1.1323204222061;\r
25         Tue, 06 Dec 2011 12:43:42 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
27         [80.220.92.23])\r
28         by mx.google.com with ESMTPS id b5sm35340022wbh.4.2011.12.06.12.43.40\r
29         (version=SSLv3 cipher=OTHER); Tue, 06 Dec 2011 12:43:40 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH 2/4] notmuch-dump: convert to notmuch-opts argument\r
33         handling.\r
34 In-Reply-To: <1323013675-6929-3-git-send-email-david@tethera.net>\r
35 References: <1323013675-6929-1-git-send-email-david@tethera.net>\r
36         <1323013675-6929-3-git-send-email-david@tethera.net>\r
37 User-Agent: Notmuch/0.10.1+59~ga1814f2 (http://notmuchmail.org) Emacs/23.3.1\r
38         (i686-pc-linux-gnu)\r
39 Date: Tue, 06 Dec 2011 22:43:38 +0200\r
40 Message-ID: <87wra9xwg5.fsf@nikula.org>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 Cc: David Bremner <bremner@debian.org>\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Tue, 06 Dec 2011 20:43:44 -0000\r
57 \r
58 On Sun,  4 Dec 2011 11:47:53 -0400, David Bremner <david@tethera.net> wrote:\r
59 > From: David Bremner <bremner@debian.org>\r
60\r
61 > The output file is handled via positional arguments. There are\r
62 > currently no "normal" options.\r
63 > ---\r
64 >  notmuch-dump.c |   32 ++++++++++++++++++++------------\r
65 >  1 files changed, 20 insertions(+), 12 deletions(-)\r
66\r
67 > diff --git a/notmuch-dump.c b/notmuch-dump.c\r
68 > index a490917..6fbdc81 100644\r
69 > --- a/notmuch-dump.c\r
70 > +++ b/notmuch-dump.c\r
71 > @@ -19,6 +19,7 @@\r
72 >   */\r
73 >  \r
74 >  #include "notmuch-client.h"\r
75 > +#include "notmuch-opts.h"\r
76 >  \r
77 >  int\r
78 >  notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
79 > @@ -41,27 +42,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
80 >      if (notmuch == NULL)\r
81 >       return 1;\r
82 >  \r
83 > -    argc--; argv++; /* skip subcommand argument */\r
84 > +    char *output_file_name = NULL;\r
85 > +    int opt_index;\r
86 >  \r
87 > -    if (argc && strcmp (argv[0], "--") != 0) {\r
88 > +    notmuch_opt_desc_t options[] = {\r
89 > +     { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },\r
90 > +     { 0, 0, 0, 0, 0 }\r
91 > +    };\r
92 > +\r
93 > +    opt_index = notmuch_parse_args (argc, argv, options, 1);\r
94 > +\r
95 > +    if (opt_index < 0) {\r
96 > +     /* diagnostics already printed */\r
97 > +     exit(1);\r
98 \r
99 return 1 rather than exit(1)?\r
100 \r
101 BR,\r
102 Jani.\r
103 \r
104 > +    }\r
105 > +\r
106 > +    if (output_file_name) {\r
107 >       fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
108 > -     output = fopen (argv[0], "w");\r
109 > +     output = fopen (output_file_name, "w");\r
110 >       if (output == NULL) {\r
111 >           fprintf (stderr, "Error opening %s for writing: %s\n",\r
112 > -                  argv[0], strerror (errno));\r
113 > +                  output_file_name, strerror (errno));\r
114 >           return 1;\r
115 >       }\r
116 > -     argc--;\r
117 > -     argv++;\r
118 >      }\r
119 >  \r
120 > -    if (argc && strcmp (argv[0], "--") == 0){\r
121 > -     argc--;\r
122 > -     argv++;\r
123 > -    }\r
124 >  \r
125 > -    if (argc) {\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
131 >           return 1;\r
132 > -- \r
133 > 1.7.7.3\r
134\r
135 > _______________________________________________\r
136 > notmuch mailing list\r
137 > notmuch@notmuchmail.org\r
138 > http://notmuchmail.org/mailman/listinfo/notmuch\r