- parse_result <- readfile emptyCP cfg_file
-
- return $
- case parse_result of
- Left err -> Left (format_cpe err)
- Right cp ->
- let cp_username = get cp "DEFAULT" "username"
- cp_password = get cp "DEFAULT" "password"
-
- cfg_username = either_to_maybe cp_username
- cfg_password = either_to_maybe cp_password
- in
- Right $ mempty { username = cfg_username,
- password = cfg_password }
+ it_exists <- doesFileExist cfg_file
+ if not it_exists then do
+ return $ Right mempty
+ else do
+ parse_result <- readfile emptyCP cfg_file
+
+ return $
+ case parse_result of
+ Left err -> Left (format_cpe err)
+ Right cp ->
+ let cp_full_stories = get cp "DEFAULT" "full_stories"
+ cp_password = get cp "DEFAULT" "password"
+ cp_username = get cp "DEFAULT" "username"
+
+ cfg_password = either_to_maybe cp_password
+ cfg_full_stories = case cp_full_stories of
+ Left _ -> False -- default
+ Right f -> f
+ cfg_username = either_to_maybe cp_username
+ in
+ Right $ mempty { full_stories = cfg_full_stories,
+ password = cfg_password,
+ username = cfg_username }