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