diff options
author | tv <tv@shackspace.de> | 2015-01-11 21:53:13 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-01-11 21:53:13 +0100 |
commit | 5273db3d5c21cd4ef331df57e09c58c93bcc3f46 (patch) | |
tree | dd62e266744497088f2749568b797793e5daf208 /Notmuch.hs | |
parent | df057aa8493de81770576c596fe6a497605481ea (diff) |
notmuch insert reply drafts
Diffstat (limited to 'Notmuch.hs')
-rw-r--r-- | Notmuch.hs | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -96,6 +96,44 @@ notmuch' args = do return (exitCode, out, err) +notmuchWithInput + :: [String] + -> LBS.ByteString + -> IO (ExitCode, LBS.ByteString, LBS.ByteString) +notmuchWithInput args input = do + (Just hin, Just hout, Just herr, ph) <- + createProcess (proc "notmuch" args) + { std_in = CreatePipe + , std_out = CreatePipe + , std_err = CreatePipe + } + LBS.hPut hin input + hClose hin + + out <- LBS.hGetContents hout + err <- LBS.hGetContents herr + + withForkWait (evaluate $ rnf out) $ \waitOut -> do + withForkWait (evaluate $ rnf err) $ \waitErr -> do + + ---- now write any input + --unless (null input) $ + -- ignoreSigPipe $ hPutStr inh input + -- hClose performs implicit hFlush, and thus may trigger a SIGPIPE + --ignoreSigPipe $ hClose inh + + -- wait on the output + waitOut + waitErr + hClose hout + hClose herr + + -- wait on the process + exitCode <- waitForProcess ph + + return (exitCode, out, err) + + search :: String -> IO (Either String [SearchResult]) search term = notmuch [ "search", "--format=json", "--format-version=2", term ] |