Skip to content

Commit

Permalink
Use yaml parser for config files.
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-b committed Dec 20, 2022
1 parent 52770da commit bb3bf17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Options/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ where

import Control.Monad (void)
import Data.Aeson qualified as Aeson
import Data.Functor.Barbie
import Options.Types
import Data.Functor.Barbie (bpure)
import Data.Yaml qualified as Yaml
import Options.Types (ClientSessionF)
import System.Directory (createDirectoryIfMissing, doesFileExist)
import System.Environment.XDG.BaseDir (getUserConfigDir)
import System.FilePath
Expand All @@ -23,7 +24,7 @@ readJSON = do
void $ createDirectoryIfMissing True configDir
let path = configDir </> "config"
doesFileExist path >>= \case
True -> Aeson.decodeFileStrict path
True -> Yaml.decodeFileThrow path
False -> pure Nothing

fromConfig :: IO (ClientSessionF Maybe)
Expand Down
1 change: 1 addition & 0 deletions cofree-bot.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ executable cofree-bot
, mtl
, optparse-applicative
, xdg-basedir
, yaml

other-modules:
, Options
Expand Down

0 comments on commit bb3bf17

Please sign in to comment.