{-# LANGUAGE OverloadedStrings #-} import System.Directory import Control.Monad.Extra import F2Md.Types import F2Md.Import import F2Md.Export import F2Md.Config import System.FilePath main :: IO () main = do (feeds, maildir, dbPath) <- getUserdata "./.f2m.json" whenJust maildir $ \root -> do mapM_ (createDirectoryIfMissing True) [root "new", root "cur", root "tmp"] feedMessages <- sequence $ (\feed -> toMessagesFromUrl (fuUrl feed) (fuLastUpdated feed)) <$> feeds mapM_ (writeMessage root) $ concat feedMessages whenJust dbPath $ \dbPath' -> updateLastUpdated dbPath' feeds feedMessages