[PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 2b / fe90aa6945e7e71dd97f873c4ae91a5be82ca5
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 60958429E38\r
6         for <notmuch@notmuchmail.org>; Sun,  4 Dec 2011 07:48:20 -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 dTvQ5mja4faG for <notmuch@notmuchmail.org>;\r
16         Sun,  4 Dec 2011 07:48:19 -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 85E6B429E30\r
21         for <notmuch@notmuchmail.org>; Sun,  4 Dec 2011 07:48:15 -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 pB4Fm8UT005363\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Sun, 4 Dec 2011 11:48:11 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.77)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RXEIS-0001oo-7m; Sun, 04 Dec 2011 11:48:08 -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 notmuch-opts argument handling.\r
34 Date: Sun,  4 Dec 2011 11:47:53 -0400\r
35 Message-Id: <1323013675-6929-3-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.7.3\r
37 In-Reply-To: <1323013675-6929-1-git-send-email-david@tethera.net>\r
38 References: <1323013675-6929-1-git-send-email-david@tethera.net>\r
39 Cc: David Bremner <bremner@debian.org>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Sun, 04 Dec 2011 15:48:21 -0000\r
53 \r
54 From: David Bremner <bremner@debian.org>\r
55 \r
56 The output file is handled via positional arguments. There are\r
57 currently no "normal" options.\r
58 ---\r
59  notmuch-dump.c |   32 ++++++++++++++++++++------------\r
60  1 files changed, 20 insertions(+), 12 deletions(-)\r
61 \r
62 diff --git a/notmuch-dump.c b/notmuch-dump.c\r
63 index a490917..6fbdc81 100644\r
64 --- a/notmuch-dump.c\r
65 +++ b/notmuch-dump.c\r
66 @@ -19,6 +19,7 @@\r
67   */\r
68  \r
69  #include "notmuch-client.h"\r
70 +#include "notmuch-opts.h"\r
71  \r
72  int\r
73  notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
74 @@ -41,27 +42,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
75      if (notmuch == NULL)\r
76         return 1;\r
77  \r
78 -    argc--; argv++; /* skip subcommand argument */\r
79 +    char *output_file_name = NULL;\r
80 +    int opt_index;\r
81  \r
82 -    if (argc && strcmp (argv[0], "--") != 0) {\r
83 +    notmuch_opt_desc_t options[] = {\r
84 +       { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },\r
85 +       { 0, 0, 0, 0, 0 }\r
86 +    };\r
87 +\r
88 +    opt_index = notmuch_parse_args (argc, argv, options, 1);\r
89 +\r
90 +    if (opt_index < 0) {\r
91 +       /* diagnostics already printed */\r
92 +       exit(1);\r
93 +    }\r
94 +\r
95 +    if (output_file_name) {\r
96         fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
97 -       output = fopen (argv[0], "w");\r
98 +       output = fopen (output_file_name, "w");\r
99         if (output == NULL) {\r
100             fprintf (stderr, "Error opening %s for writing: %s\n",\r
101 -                    argv[0], strerror (errno));\r
102 +                    output_file_name, strerror (errno));\r
103             return 1;\r
104         }\r
105 -       argc--;\r
106 -       argv++;\r
107      }\r
108  \r
109 -    if (argc && strcmp (argv[0], "--") == 0){\r
110 -       argc--;\r
111 -       argv++;\r
112 -    }\r
113  \r
114 -    if (argc) {\r
115 -       query_str = query_string_from_args (notmuch, argc, argv);\r
116 +    if (opt_index < argc) {\r
117 +       query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);\r
118         if (query_str == NULL) {\r
119             fprintf (stderr, "Out of memory.\n");\r
120             return 1;\r
121 -- \r
122 1.7.7.3\r
123 \r