Skip to content

Instantly share code, notes, and snippets.

@patrickt

patrickt/hack.diff

Created Jul 2, 2020
Embed
What would you like to do?
diff --git i/summoner-cli/src/Summoner/Default.hs w/summoner-cli/src/Summoner/Default.hs
index 41dfaa6..6a25abe 100644
--- i/summoner-cli/src/Summoner/Default.hs
+++ w/summoner-cli/src/Summoner/Default.hs
@@ -29,12 +29,12 @@ import Relude.Extra.Enum (prev)
import Data.Time (getCurrentTime, toGregorian, utctDay)
import NeatInterpolation (text)
-import System.Directory (getHomeDirectory)
+import System.Directory (getHomeDirectory, doesFileExist)
import System.FilePath ((</>))
import Summoner.GhcVer (GhcVer, showGhcVer)
import Summoner.License (LicenseName (MIT))
-
+import qualified System.Environment.XDG.BaseDir as XDG
-- | Default GHC version is the latest available.
defaultGHC :: GhcVer
@@ -60,7 +60,13 @@ defaultTomlFile :: FilePath
defaultTomlFile = ".summoner.toml"
defaultConfigFile :: IO FilePath
-defaultConfigFile = (</> defaultTomlFile) <$> getHomeDirectory
+defaultConfigFile = do
+ xdg <- XDG.getUserConfigFile "summoner" "summoner.toml"
+ exists <- doesFileExist xdg
+ if exists
+ then pure xdg
+ else (</> defaultTomlFile) <$> getHomeDirectory
+
defaultDescription :: Text
defaultDescription = "See README for more info"
diff --git i/summoner-cli/summoner.cabal w/summoner-cli/summoner.cabal
index a569dc1..2c4c834 100644
--- i/summoner-cli/summoner.cabal
+++ w/summoner-cli/summoner.cabal
@@ -150,6 +150,7 @@ library
, optparse-applicative ^>= 0.15
, process ^>= 1.6.1.0
, shellmet ^>= 0.0.3.0
+ , xdg-basedir ^>= 0.2.2
, text ^>= 1.2.3.0
, time >= 1.8 && < 1.11
, tomland ^>= 1.3.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.