Coverage report: /home/ellis/comp/core/lib/cli/tools/mail.lisp

KindCoveredAll%
expression0101 0.0
branch04 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; mail.lisp --- CLI Mail Tools
2
 
3
 ;; 
4
 
5
 ;;; Code:
6
 (in-package :cli/tools/mail)
7
 
8
 (deferror mail-error (simple-error) () (:auto t))
9
 
10
 (defvar *notmuch* (find-exe "notmuch"))
11
 (defvar *offlineimap* (find-exe "offlineimap"))
12
 (defvar *mail-program* :emacs)
13
 
14
 (defun %notmuch (args output &optional (wait t))
15
   (sb-ext:run-program *notmuch* (or (flatten args) nil) :output output :wait wait))
16
 
17
 (defun run-notmuch* (args &optional (output *standard-output*))
18
   (let ((proc (%notmuch args output)))
19
     (if (eq 0 (sb-ext:process-exit-code proc))
20
         nil
21
         (mail-error "NOTMUCH command failed: ~A ~A" *notmuch* (or args "")))))
22
 
23
 (defun run-notmuch (&rest args)
24
   (run-notmuch* args))
25
 
26
 (defun run-offlineimap* (args &optional (output *standard-output*) wait)
27
   (let ((proc (sb-ext:run-program *offlineimap* (or (flatten args) nil) :output output :wait wait)))
28
     (when wait
29
       (if (eq 0 (sb-ext:process-exit-code proc))
30
           nil
31
           (mail-error "OFFLINEIMAP command failed: ~A ~A" *offlineimap* (or args ""))))))
32
 
33
 (defun run-offlineimap (&optional wait args)
34
   (run-offlineimap* args *standard-output* wait))
35
 
36
 (defun notmuch-search (query)
37
   (let* ((proc (%notmuch `("search" "--format=sexp" ,query) :stream nil))
38
          (out (sb-ext:process-output proc)))
39
     (read out)))
40
 
41
 (defun notmuch-show (query)
42
   (let* ((proc (%notmuch `("show" "--format=sexp" ,query) :stream nil))
43
          (out (sb-ext:process-output proc)))
44
     (read out)))
45
 
46
 (defun notmuch-count (query)
47
   (let* ((proc (%notmuch `("count" ,query) :stream nil))
48
          (out (sb-ext:process-output proc)))
49
     (read out)))
50
 
51
 (defun notmuch-tag (query &rest args)
52
   (apply 'run-notmuch "tag" (push query args)))
53
 
54
 (defun notmuch-address (query &rest args)
55
   (let* ((proc (%notmuch `("address" "--format=sexp" ,@args ,query) :stream nil))
56
          (out (sb-ext:process-output proc)))
57
     (read out)))