[PATCH v3 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / 3f / 5620ec247996fe696644efb84bc78125a4cf08
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 B4835429E2E\r
6         for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 09:45:46 -0700 (PDT)\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 d8ej3+nPMGCs for <notmuch@notmuchmail.org>;\r
16         Sat, 29 Oct 2011 09:45:45 -0700 (PDT)\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 19BE0429E2F\r
21         for <notmuch@notmuchmail.org>; Sat, 29 Oct 2011 09:45:42 -0700 (PDT)\r
22 Received: from zancas.localnet\r
23         (fctnnbsc36w-156034064058.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
24         [156.34.64.58]) (authenticated bits=0)\r
25         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id p9TGjYH2022540\r
26         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
27         Sat, 29 Oct 2011 13:45:37 -0300\r
28 Received: from bremner by zancas.localnet with local (Exim 4.76)\r
29         (envelope-from <bremner@tethera.net>)\r
30         id 1RKC2I-0002i3-Dd; Sat, 29 Oct 2011 13:45:34 -0300\r
31 From: David Bremner <david@tethera.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH] contrib/nmbug: new script for sharing tags with prefix\r
34         notmuch::\r
35 Date: Sat, 29 Oct 2011 13:45:07 -0300\r
36 Message-Id: <1319906707-10141-2-git-send-email-david@tethera.net>\r
37 X-Mailer: git-send-email 1.7.6.3\r
38 In-Reply-To: <1319906707-10141-1-git-send-email-david@tethera.net>\r
39 References: <1319857491-12298-5-git-send-email-david@tethera.net>\r
40         <1319906707-10141-1-git-send-email-david@tethera.net>\r
41 Cc: David Bremner <bremner@debian.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Sat, 29 Oct 2011 16:45:47 -0000\r
55 \r
56 From: David Bremner <bremner@debian.org>\r
57 \r
58 In this initial version, we take care of only the base import and\r
59 export of the appropriate tags in line oriented format amenable to\r
60 easy merging.\r
61 \r
62 The current plan to use git to share tags and resolve conflicts.\r
63 ---\r
64  contrib/nmbug |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
65  1 files changed, 69 insertions(+), 0 deletions(-)\r
66  create mode 100755 contrib/nmbug\r
67 \r
68 diff --git a/contrib/nmbug b/contrib/nmbug\r
69 new file mode 100755\r
70 index 0000000..e9d1b14\r
71 --- /dev/null\r
72 +++ b/contrib/nmbug\r
73 @@ -0,0 +1,69 @@\r
74 +#!/bin/bash\r
75 +# Copyright (c) 2011 David Bremner\r
76 +# License: same as notmuch\r
77 +\r
78 +NMHOME=${HOME}/.nmbug\r
79 +\r
80 +NMTAGS=($(notmuch search --output=tags "*"|grep "^notmuch::"))\r
81 +\r
82 +function dump() {\r
83 +    notmuch dump -- $(printf  " tag:%s" ${NMTAGS[*]}) |\\r
84 +    while read  -r msgid rest \r
85 +    do\r
86 +       outfile=$NMHOME/tags/$(echo $msgid | sha1sum - | cut -f1 -d' ')\r
87 +       echo $outfile\r
88 +       printf "msg-id: %s\n" $msgid > $outfile\r
89 +       tmp=${rest#\(}\r
90 +       read -r -a tags <<<${tmp%\)};\r
91 +       for tag in "${tags[@]}"; do\r
92 +           case $tag in\r
93 +               notmuch::*)\r
94 +                   echo "tag: $tag" >> $outfile\r
95 +                   ;;\r
96 +               *)\r
97 +               # nothing\r
98 +           esac\r
99 +       done\r
100 +    done\r
101 +    \r
102 +}\r
103 +\r
104 +function cat_file() {\r
105 +    tags=""\r
106 +    id=""\r
107 +    cat $1 |\\r
108 +    while read -r what data \r
109 +    do\r
110 +       case $what in\r
111 +           msg-id:)\r
112 +               printf "%s (" $data \r
113 +               ;;\r
114 +           tag:)\r
115 +               printf "%s " $data\r
116 +               ;;\r
117 +           *)\r
118 +               echo "Syntax error $what"\r
119 +               exit 1\r
120 +       esac\r
121 +    done\r
122 +    echo ")"\r
123 +}\r
124 +\r
125 +function restore() {\r
126 +    find $NMHOME/tags -type f |\\r
127 +    while read -r filename\r
128 +    do\r
129 +       cat_file $filename\r
130 +    done | notmuch restore --match=notmuch::\r
131 +}\r
132 +case $1 in\r
133 +    dump)\r
134 +       dump\r
135 +       ;;\r
136 +    restore)\r
137 +       restore\r
138 +       ;;\r
139 +    *)\r
140 +       echo unknown command $1;\r
141 +esac\r
142 +   \r
143 -- \r
144 1.7.6.3\r
145 \r