1 Return-Path: <novalazy@gmail.com>
\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 0152E431FDC
\r
6 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:10 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id KwdukMViGVzD for <notmuch@notmuchmail.org>;
\r
17 Wed, 25 Jul 2012 06:44:09 -0700 (PDT)
\r
18 Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com
\r
19 [209.85.160.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 8D937431FAE
\r
22 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:09 -0700 (PDT)
\r
23 Received: by mail-pb0-f53.google.com with SMTP id rr13so1767731pbb.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:09 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
27 bh=znSJ6OY/HEngoNx3sDcCsFahxHQeS923hhE/P7Llewk=;
\r
28 b=XrHMAxzY6Z8ezbaBCaWCJGg0/5MaYWkZ/ztJxQ0iDdpIQPY4l/DP+voBeA0bBLWN4p
\r
29 QW9JXTI4t7PcB0xImio0GDqYtkxSNbiZnRreACp+YDCsc9lIMUPPs66FEnYNwvE03RYi
\r
30 la1XDnFbR1uk8MZhERd1n2Uu+yCruw1z6Rwnu08kYU8PXtsHKjH/7uah58e2SKsz8MJA
\r
31 FIAzjquErcufYkomhLHJj5ZwlfEd85OS4dpHkLSQ5op4zJgvER96zx8xPxYhLbF1S2wH
\r
32 iomXCzh2dK/PBGByWBkZwgzsMEvvXw5cDVZ6Dg8TTp6eMPsnalmPjiiMGa5HlLPew/50
\r
34 Received: by 10.68.231.10 with SMTP id tc10mr53678564pbc.107.1343223849378;
\r
35 Wed, 25 Jul 2012 06:44:09 -0700 (PDT)
\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.
\r
38 by mx.google.com with ESMTPS id ny4sm14408899pbb.57.2012.07.25.06.44.06
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Wed, 25 Jul 2012 06:44:08 -0700 (PDT)
\r
41 From: Peter Wang <novalazy@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH 10/18] insert: parse command-line tag operations
\r
44 Date: Wed, 25 Jul 2012 23:42:39 +1000
\r
45 Message-Id: <1343223767-9812-10-git-send-email-novalazy@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.4.4
\r
47 In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
48 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Wed, 25 Jul 2012 13:44:11 -0000
\r
63 Parse +tag and -tag on the 'insert' command-line.
\r
64 Issue a warning about ambiguous -tag arguments which don't follow
\r
65 +tag nor an explicit option list terminator.
\r
67 notmuch-insert.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
\r
68 1 files changed, 50 insertions(+), 0 deletions(-)
\r
70 diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
71 index 4fb3ea3..6db03e3 100644
\r
72 --- a/notmuch-insert.c
\r
73 +++ b/notmuch-insert.c
\r
75 #include <sys/stat.h>
\r
80 + notmuch_bool_t remove;
\r
83 static notmuch_bool_t
\r
84 check_folder_name (const char *folder)
\r
86 @@ -236,8 +241,11 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
87 const char **new_tags;
\r
88 size_t new_tags_length;
\r
89 const char *folder = NULL;
\r
90 + tag_operation_t *tag_ops;
\r
91 + int tag_ops_count = 0;
\r
94 + notmuch_bool_t warn_tag_rem;
\r
97 notmuch_opt_desc_t options[] = {
\r
98 @@ -253,6 +261,48 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
\r
102 + if (opt_index > 0 && strcmp (argv[opt_index - 1], "--") == 0) {
\r
103 + warn_tag_rem = FALSE;
\r
105 + warn_tag_rem = TRUE;
\r
108 + /* Array of tagging operations (add or remove), terminated with an
\r
109 + * empty element. */
\r
110 + tag_ops = talloc_array (ctx, tag_operation_t, argc - opt_index + 1);
\r
111 + if (tag_ops == NULL) {
\r
112 + fprintf (stderr, "Out of memory.\n");
\r
116 + for (; opt_index < argc; opt_index++) {
\r
117 + if (argv[opt_index][0] == '+') {
\r
118 + tag_ops[tag_ops_count].tag = argv[opt_index] + 1;
\r
119 + tag_ops[tag_ops_count].remove = FALSE;
\r
121 + warn_tag_rem = FALSE;
\r
122 + } else if (argv[opt_index][0] == '-') {
\r
123 + if (warn_tag_rem) {
\r
125 + "Warning: ambiguous argument treated as tag removal: %s\n",
\r
126 + argv[opt_index]);
\r
128 + tag_ops[tag_ops_count].tag = argv[opt_index] + 1;
\r
129 + tag_ops[tag_ops_count].remove = TRUE;
\r
136 + tag_ops[tag_ops_count].tag = NULL;
\r
138 + if (opt_index != argc) {
\r
139 + fprintf (stderr, "Error: bad argument to notmuch insert: %s\n",
\r
140 + argv[opt_index]);
\r
144 config = notmuch_config_open (ctx, NULL, NULL);
\r
145 if (config == NULL)
\r