imp: cli: improve debug output for finding config file
This commit is contained in:
parent
46897cd30b
commit
2db4b8ed56
@ -93,17 +93,19 @@ confLookup cmd Conf{confSections} =
|
|||||||
-- Otherwise this returns the parsed Conf, and the file path.
|
-- Otherwise this returns the parsed Conf, and the file path.
|
||||||
getConf :: RawOpts -> IO (Conf, Maybe FilePath)
|
getConf :: RawOpts -> IO (Conf, Maybe FilePath)
|
||||||
getConf rawopts = do
|
getConf rawopts = do
|
||||||
defconfpaths <- defaultConfFilePaths
|
-- As in Cli.hs, conf debug output always goes to stderr;
|
||||||
defconffiles <- fmap catMaybes $ forM defconfpaths $ \f -> do
|
-- that's ok as conf is a hledger cli feature for now.
|
||||||
exists <- doesFileExist f
|
case confFileSpecFromRawOpts rawopts of
|
||||||
return $ if exists then Just f else Nothing
|
NoConfFile -> return $ traceAt 1 "ignoring config files" (nullconf, Nothing)
|
||||||
case (confFileSpecFromRawOpts rawopts, defconffiles) of
|
SomeConfFile f -> getCurrentDirectory >>= flip expandPath f >>= readConfFile . dbg1 "using specified config file"
|
||||||
-- As in Cli.hs, conf debug output always goes to stderr;
|
AutoConfFile -> do
|
||||||
-- that's ok as conf is a hledger cli feature for now.
|
defconfpaths <- defaultConfFilePaths
|
||||||
(SomeConfFile f, _) -> getCurrentDirectory >>= flip expandPath f >>= readConfFile
|
conffiles <- fmap catMaybes $ forM defconfpaths $ \f -> do
|
||||||
(NoConfFile, _) -> return $ traceAt 1 "ignoring config files" (nullconf, Nothing)
|
exists <- doesFileExist f
|
||||||
(AutoConfFile,f:_) -> dbg8IO "found config files" defconffiles >> dbg1IO "using config file" f >> readConfFile f
|
return $ if exists then Just f else Nothing
|
||||||
(AutoConfFile,[] ) -> return $ traceAt 1 "no config file found" (nullconf, Nothing)
|
case conffiles of
|
||||||
|
f:_ -> dbg8IO "found config files" conffiles >> dbg1IO "using config file" f >> readConfFile f
|
||||||
|
[] -> return $ traceAt 1 "no config file found" (nullconf, Nothing)
|
||||||
|
|
||||||
-- | Read this config file and parse its contents, or raise an error.
|
-- | Read this config file and parse its contents, or raise an error.
|
||||||
readConfFile :: FilePath -> IO (Conf, Maybe FilePath)
|
readConfFile :: FilePath -> IO (Conf, Maybe FilePath)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user