diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2009-09-14 04:39:21 +0200 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2009-09-14 04:39:21 +0200 |
commit | 7514c05975601d5816c696a8072b23142e8f0802 (patch) | |
tree | 2a477914adb81aa751f947a77ac5207c38e03fe6 /Main.hs | |
parent | 51b7cdce37a7e0469d02d3aade3a1966907271ef (diff) | |
download | xmobar-7514c05975601d5816c696a8072b23142e8f0802.tar.gz xmobar-7514c05975601d5816c696a8072b23142e8f0802.tar.bz2 |
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
Diffstat (limited to 'Main.hs')
-rw-r--r-- | Main.hs | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -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 |