Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / c7 / bd488a2a61a747905b8298af51b466564c5a07
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 050B9429E39\r
6         for <notmuch@notmuchmail.org>; Thu,  1 Dec 2011 22:42:14 -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 0k7z8+xtatHP for <notmuch@notmuchmail.org>;\r
16         Thu,  1 Dec 2011 22:42:13 -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 4874A429E36\r
21         for <notmuch@notmuchmail.org>; Thu,  1 Dec 2011 22:42:13 -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 pB26g50V010487\r
25         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
26         Fri, 2 Dec 2011 02:42:07 -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 1RWMou-00038l-Pr; Thu, 01 Dec 2011 22:42:04 -0800\r
30 From: David Bremner <david@tethera.net>\r
31 To: notmuch@notmuchmail.org\r
32 Subject: [RFC Patch v2 2/3] notmuch-dump: convert to notmuch-opts argument\r
33         handling.\r
34 Date: Thu,  1 Dec 2011 22:41:53 -0800\r
35 Message-Id: <1322808114-11854-2-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.5.4\r
37 In-Reply-To: <1322808114-11854-1-git-send-email-david@tethera.net>\r
38 References: <1322702130-26068-3-git-send-email-bremner@debian.org>\r
39         <1322808114-11854-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: Fri, 02 Dec 2011 06:42:14 -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 |   27 +++++++++++++++------------\r
61  1 files changed, 15 insertions(+), 12 deletions(-)\r
62 \r
63 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
64 index 0475eb9..9e0c91d 100644\r
65 --- a/notmuch-dump.c\r
66 +++ b/notmuch-dump.c\r
67 @@ -19,6 +19,7 @@\r
68   */\r
69  \r
70  #include "notmuch-client.h"\r
71 +#include "notmuch-opts.h"\r
72  \r
73  int\r
74  notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
75 @@ -41,27 +42,29 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
76      if (notmuch == NULL)\r
77         return 1;\r
78  \r
79 -    argc--; argv++; /* skip subcommand argument */\r
80 +    char *output_file_name = NULL;\r
81 +    int opt_index;\r
82  \r
83 -    if (argc && strcmp (argv[0], "--") != 0) {\r
84 +    notmuch_opt_desc_t options[] = {\r
85 +       { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },\r
86 +       { 0, 0, 0, 0, 0 }\r
87 +    };\r
88 +\r
89 +    opt_index = notmuch_parse_args (argc, argv, options, 1);\r
90 +\r
91 +    if (output_file_name) {\r
92         fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
93 -       output = fopen (argv[0], "w");\r
94 +       output = fopen (output_file_name, "w");\r
95         if (output == NULL) {\r
96             fprintf (stderr, "Error opening %s for writing: %s\n",\r
97 -                    argv[0], strerror (errno));\r
98 +                    output_file_name, strerror (errno));\r
99             return 1;\r
100         }\r
101 -       argc--;\r
102 -       argv++;\r
103      }\r
104  \r
105 -    if (argc && strcmp (argv[0], "--") == 0){\r
106 -       argc--;\r
107 -       argv++;\r
108 -    }\r
109  \r
110 -    if (argc) {\r
111 -       query_str = query_string_from_args (notmuch, argc, argv);\r
112 +    if (opt_index < argc) {\r
113 +       query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);\r
114         if (query_str == NULL) {\r
115             fprintf (stderr, "Out of memory.\n");\r
116             return 1;\r
117 -- \r
118 1.7.5.4\r
119 \r