module Dodge.Config.Load
    ( loadDodgeConfig
    ) where
import Dodge.Config.Data

import Data.Aeson
import System.Directory

loadDodgeConfig :: IO Configuration
loadDodgeConfig = do
    fExists <- doesFileExist "data/dodge.config.json"
    if fExists
    then do
        mayConfig <- decodeFileStrict "data/dodge.config.json"
        case mayConfig of
          Just config -> return config
          Nothing -> do
            putStrLn "invalid data/dodge.config.json, loading defaults"
            return defaultConfig
    else do
        putStrLn "No data/data/dodge.config.json found, loading defaults"
        return defaultConfig
