aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
blob: f3f8a5a83c232eb6f663ef195d2c8fbc5d4fae18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# 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) <- getUserdata "./.f2m.json"
  whenJust maildir $ \root -> do
    mapM_ (createDirectoryIfMissing True)
      [root </> "new", root </> "cur", root </> "tmp"]
    messages <- (fmap concat . sequence) $
      (\feed -> toMessagesFromUrl (url feed) (lastUpdated feed)) <$> feeds
    mapM_ (writeMessage root) messages