{-# LANGUAGE OverloadedStrings #-}
module Clod.Config
(
configDirName
, clodIgnoreFile
, clodConfigDir
, getDataFileName
) where
import System.Environment (lookupEnv)
import System.FilePath ((</>))
import qualified Paths_clod as Paths
configDirName :: IO String
configDirName :: IO String
configDirName = do
envValue <- String -> IO (Maybe String)
lookupEnv String
"CLOD_DIR"
return $ case envValue of
Just String
value | Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
value) -> String
value
Maybe String
_ -> String
".clod"
clodIgnoreFile :: IO String
clodIgnoreFile :: IO String
clodIgnoreFile = do
envValue <- String -> IO (Maybe String)
lookupEnv String
"CLODIGNORE"
return $ case envValue of
Just String
value | Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
value) -> String
value
Maybe String
_ -> String
".clodignore"
clodConfigDir :: FilePath -> IO FilePath
clodConfigDir :: String -> IO String
clodConfigDir String
rootPath = do
dirName <- IO String
configDirName
return $ rootPath </> dirName
getDataFileName :: FilePath -> IO FilePath
getDataFileName :: String -> IO String
getDataFileName = String -> IO String
Paths.getDataFileName