fixed wrong-default-config-path

This commit is contained in:
Dmitry Zuikov 2023-02-15 07:43:52 +03:00
parent 8fb6fc1281
commit 73bf0e9f17
3 changed files with 14 additions and 4 deletions

View File

@ -154,3 +154,5 @@ fixme-set "workflow" "backlog" "9v1QCP5JAL"
fixme-set "workflow" "backlog" "G9xp6QQkRE"
fixme-merged "AmtqsgpimE" "AEuRHd5sWC"
fixme-set "workflow" "wip" "DZyVAuBYzB"

View File

@ -1,6 +1,8 @@
## 2023-02-15
FIXME: wrong-default-config-path
TODO: make-key-optional-parameter
-k should be an optional parameter

View File

@ -77,9 +77,11 @@ peerConfigRead mbfp = do
xdg <- peerConfigDefault
let cfgPath = fromMaybe xdg mbfp </> cfgName
let cfgPath = fromMaybe xdg mbfp
let dir = takeDirectory cfgPath
debug $ "searching config" <+> pretty cfgPath
here <- liftIO $ doesFileExist cfgPath
if not here then do
@ -91,7 +93,11 @@ peerConfigRead mbfp = do
-- FIXME: config-parse-error-handling
-- Handle parse errors
confData <- liftIO $ readFile cfgPath <&> parseTop
debug $ pretty cfgPath
confData <- liftIO $ readFile cfgPath <&> parseTop <&> either mempty id
debug $ pretty confData
config <- flip transformBiM confData $ \case
List co (Key "key" [LitStrVal p]) -> do
@ -104,7 +110,7 @@ peerConfigRead mbfp = do
x -> pure x
pure $ PeerConfig $ fromRight mempty config
pure $ PeerConfig config
instance {-# OVERLAPPABLE #-} (IsString b, HasCfgKey a (Maybe b)) => HasCfgValue a (Maybe b) where