Use XDG config directory as default config path
- Look for config at $XDG_CONFIG_HOME/converge/config.yaml by default - --config still overrides to an explicit path - Falls back to single-repo --repo mode if no config file found - New defaultConfigPath and configFileExists helpers in Converge module
This commit is contained in:
+11
-1
@@ -9,6 +9,8 @@ module Converge (
|
||||
Config (..),
|
||||
loadConfig,
|
||||
configToOptions,
|
||||
defaultConfigPath,
|
||||
configFileExists,
|
||||
|
||||
-- * Running
|
||||
runConverge,
|
||||
@@ -31,7 +33,7 @@ import Data.Maybe (fromMaybe)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Yaml (FromJSON (..), decodeFileThrow, withObject, (.:), (.:?))
|
||||
import System.Directory (getCurrentDirectory)
|
||||
import System.Directory (XdgDirectory (XdgConfig), doesFileExist, getCurrentDirectory, getXdgDirectory)
|
||||
import System.Exit (ExitCode (..))
|
||||
import System.FSNotify
|
||||
import System.FilePath (isAbsolute, (</>))
|
||||
@@ -114,6 +116,14 @@ configToOptions cfg =
|
||||
, optDebounceMs = fromMaybe 5000 (cfgDebounceMs cfg)
|
||||
}
|
||||
|
||||
-- | The default XDG config file path: @$XDG_CONFIG_HOME/converge/config.yaml@.
|
||||
defaultConfigPath :: IO FilePath
|
||||
defaultConfigPath = (</> "converge/config.yaml") <$> getXdgDirectory XdgConfig ""
|
||||
|
||||
-- | Check whether the default config file exists.
|
||||
configFileExists :: IO Bool
|
||||
configFileExists = defaultConfigPath >>= doesFileExist
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- Running
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user