From 7514c05975601d5816c696a8072b23142e8f0802 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Mon, 14 Sep 2009 04:39:21 +0200 Subject: Parse config file more intelligently. Ignore-this: 9d6cd7536b6df73f3af44b7a74b826a1 Using parsec and action-permutations, config options may be permuted or left out (to be replaced by the default configuration option). This patch improves forwards compatibility with xmobar (ex. the addition of lowerOnStart broke many configs), and provides some help to find typos in the config. The commands section is still parsed with Read however. darcs-hash:20090914023921-1499c-b73a792ccfafd50d31878e35f928facb50748531.gz --- Main.hs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Main.hs') diff --git a/Main.hs b/Main.hs index c8ce30d..44dda60 100644 --- a/Main.hs +++ b/Main.hs @@ -64,11 +64,8 @@ readConfig :: FilePath -> IO Config readConfig f = do file <- fileExist f s <- if file then readFileSafe f else error $ f ++ ": file not found!\n" ++ usage - case reads s of - [(conf,_)] -> return conf - [] -> error $ f ++ ": configuration file contains errors!\n" ++ usage - _ -> error ("Some problem occured. Aborting...") - + either (\err -> error $ f ++ ": configuration file contains errors at:\n" ++ show err) + return $ parseConfig s -- | Read default configuration file or load the default config readDefaultConfig :: IO Config readDefaultConfig = do -- cgit v1.2.3