]> git.notmuchmail.org Git - notmuch/blob - notmuch
use logging.debug for debug output. Implement notmuch search-tags
[notmuch] / notmuch
1 #!/usr/bin/env python
2 """This is a notmuch implementation in python. It's goal is to allow running the test suite on the cnotmuch python bindings."""
3 import sys, os
4 from cnotmuch.notmuch import Database, Query
5 #TODO Handle variable: NOTMUCH-CONFIG
6
7 #-------------------------------------------------------------------------
8 HELPTEXT="""The notmuch mail system.
9
10 Usage: notmuch <command> [args...]
11
12 Where <command> and [args...] are as follows:
13
14         setup   Interactively setup notmuch for first use.
15
16         new     [--verbose]
17
18                 Find and import new messages to the notmuch database.
19
20         search  [options...] <search-terms> [...]
21
22                 Search for messages matching the given search terms.
23
24         show    <search-terms> [...]
25
26                 Show all messages matching the search terms.
27
28         count   <search-terms> [...]
29
30                 Count messages matching the search terms.
31
32         reply   [options...] <search-terms> [...]
33
34                 Construct a reply template for a set of messages.
35
36         tag     +<tag>|-<tag> [...] [--] <search-terms> [...]
37
38                 Add/remove tags for all messages matching the search terms.
39
40         dump    [<filename>]
41
42                 Create a plain-text dump of the tags for each message.
43
44         restore <filename>
45
46                 Restore the tags from the given dump file (see 'dump').
47
48         search-tags     [<search-terms> [...] ]
49
50                 List all tags found in the database or matching messages.
51
52         help    [<command>]
53
54                 This message, or more detailed help for the named command.
55
56 Use "notmuch help <command>" for more details on each command.
57 And "notmuch help search-terms" for the common search-terms syntax.
58 """
59 #-------------------------------------------------------------------------
60 #TODO: replace the dynamic pieces
61 USAGE="""Notmuch is configured and appears to have a database. Excellent!
62
63 At this point you can start exploring the functionality of notmuch by
64 using commands such as:
65
66         notmuch search tag:inbox
67
68         notmuch search to:"Sebastian Spaeth"
69
70         notmuch search from:"Sebastian@SSpaeth.de"
71
72         notmuch search subject:"my favorite things"
73
74 See "notmuch help search" for more details.
75
76 You can also use "notmuch show" with any of the thread IDs resulting
77 from a search. Finally, you may want to explore using a more sophisticated
78 interface to notmuch such as the emacs interface implemented in notmuch.el
79 or any other interface described at http://notmuchmail.org
80
81 And don't forget to run "notmuch new" whenever new mail arrives.
82
83 Have fun, and may your inbox never have much mail.
84 """
85 #-------------------------------------------------------------------------
86 if __name__ == '__main__':
87
88    # Handle command line options
89    # No option 
90    if len(sys.argv) == 1:
91       print USAGE
92
93    elif sys.argv[1] == 'setup':
94        """ Interactively setup notmuch for first use. """
95        print "Not implemented."
96
97    elif sys.argv[1] == 'help':
98        if len(sys.argv) == 2: print HELPTEXT
99        else: print "Not implemented"
100
101    elif sys.argv[1] == 'new':
102        #TODO: handle --verbose
103        print "Not implemented."
104
105    elif sys.argv[1] == 'search-tags':
106       if len(sys.argv) == 2:
107          print("\n".join(Database().get_all_tags()))
108
109       else: print "Not implemented"
110
111    else:
112        # unknown command
113        print "Error: Unknown command '%s' (see \"notmuch help\")" % sys.argv[1]
114
115
116    #TODO: implement
117    """
118 search  [options...] <search-terms> [...]
119
120         Search for messages matching the given search terms.
121
122 show    <search-terms> [...]
123
124         Show all messages matching the search terms.
125
126 count   <search-terms> [...]
127
128         Count messages matching the search terms.
129
130 reply   [options...] <search-terms> [...]
131
132         Construct a reply template for a set of messages.
133
134 tag     +<tag>|-<tag> [...] [--] <search-terms> [...]
135
136         Add/remove tags for all messages matching the search terms.
137
138 dump    [<filename>]
139
140         Create a plain-text dump of the tags for each message.
141
142 restore <filename>
143         search-tags     [<search-terms> [...] ]
144
145                 List all tags found in the database or matching messages.
146    """