mirror of
https://git.nerfingen.de/nerf/choirMail.git
synced 2025-06-08 01:31:16 +00:00
some minor code cleanup
This commit is contained in:
parent
5c203e5a95
commit
72e53eea4f
3 changed files with 17 additions and 8 deletions
11
app/Main.hs
11
app/Main.hs
|
@ -37,20 +37,17 @@ findChoirDay today table = maybe
|
|||
main' :: App ()
|
||||
main' = do
|
||||
args <- liftIO getArgs
|
||||
case L.uncons args of
|
||||
Nothing -> fail "We need exactly one config path as option"
|
||||
Just (headArgs,_) -> do
|
||||
case args of
|
||||
[] -> fail "Please provide a config file"
|
||||
(headArgs : _) -> do
|
||||
config <- parseConfigFile headArgs
|
||||
-- we want to handle these while we have the config in scope
|
||||
result <- liftIO $ runApp $ do
|
||||
handleE (\error' -> reportErrorMail config error') $ do
|
||||
bs <- request
|
||||
table <- except $ parseBString bs
|
||||
today <- liftIO getToday
|
||||
record <- except $ findChoirDay today table
|
||||
send (mailDomain config) (mailUsername config) (mailPassword config) (mailTo config) (mailFrom config) (mailSubject record) (mailText record)
|
||||
case result of
|
||||
Right x -> return x
|
||||
Left error' -> reportErrorMail config error'
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue