diff options
author | Joris | 2016-11-20 18:26:07 +0100 |
---|---|---|
committer | Joris | 2016-11-20 18:26:07 +0100 |
commit | 74aff92204f70a6f113039fe90d332b44f9493c2 (patch) | |
tree | eb9b6ecb3edf55be352737db9cb72a7f1c2ac87e /src/Conf.hs | |
parent | ae45764821dc3c04eeb8c2171f14d36256ce4027 (diff) |
Enable multi-urls in config file
Diffstat (limited to 'src/Conf.hs')
-rw-r--r-- | src/Conf.hs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Conf.hs b/src/Conf.hs index fccf2a5..03f8dc2 100644 --- a/src/Conf.hs +++ b/src/Conf.hs @@ -6,27 +6,32 @@ module Conf ) where import Data.Text (Text) +import qualified Data.Text as T import qualified Data.ConfigManager as Conf import Data.Time.Clock (NominalDiffTime) import Model.URL data Conf = Conf - { url :: URL + { urls :: [URL] , mailFrom :: Text , mailTo :: [Text] , properties :: [Text] , listenInterval :: NominalDiffTime } deriving Show -parse :: FilePath -> IO (Either Text Conf) -parse path = - (flip fmap) (Conf.readConfig path) (\configOrError -> do - conf <- configOrError - Conf <$> - Conf.lookup "url" conf <*> - Conf.lookup "mailFrom" conf <*> - Conf.lookup "mailTo" conf <*> - Conf.lookup "properties" conf <*> - Conf.lookup "listenInterval" conf - ) +parse :: FilePath -> IO Conf +parse path = do + conf <- + (flip fmap) (Conf.readConfig path) (\configOrError -> do + conf <- configOrError + Conf <$> + Conf.lookup "urls" conf <*> + Conf.lookup "mailFrom" conf <*> + Conf.lookup "mailTo" conf <*> + Conf.lookup "properties" conf <*> + Conf.lookup "listenInterval" conf + ) + case conf of + Left msg -> error (T.unpack msg) + Right c -> return c |