From 15646fa9e492ded6978620e8e17239c636cfbb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Wed, 30 Sep 2020 10:56:37 +0200 Subject: kmein config: add saveAttachment action --- src/Notmuch.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/Notmuch.hs b/src/Notmuch.hs index f86bd3d..0781650 100644 --- a/src/Notmuch.hs +++ b/src/Notmuch.hs @@ -170,6 +170,16 @@ notmuchShow term = do either error id (eitherDecodeLenient' c') +notmuchShowPartRaw :: String -> Int -> IO (Either String LBS8.ByteString) +notmuchShowPartRaw term partId = do + (exitCode, out, err) <- + notmuch' [ "show", "--format=raw" + , "--part=" <> show partId + , term ] + return $ case exitCode of + ExitSuccess -> Right out + _ -> Left $ show exitCode <> ": " <> LBS8.unpack err + notmuchShowPart :: String -> Int -> IO (Either String MessagePart) notmuchShowPart term partId = do -- TODO handle partId == 0 and partId > N -- cgit v1.2.3