gdritter repos config-ini / 2d143c5
Some style changes for bidir example Getty Ritter 7 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Collapse all Expand all
2727 , _confConfigFile = Nothing
2828 }
2929
30 parseConfig :: IniSpec Config ()
31 parseConfig = section "NETWORK" $ do
30 configSpec :: IniSpec Config ()
31 configSpec = section "NETWORK" $ do
3232 confUsername .= field "user" text
3333 & comment [ "your username" ]
3434 confPort .= field "port" number
5151
5252 main :: IO ()
5353 main = do
54 let s = parseIniFile sampleConfig parseConfig example
54 let s = parseIniFile sampleConfig configSpec example
5555 print s
5656 case s of
5757 Left err -> putStrLn err
5858 Right p -> do
5959 putStrLn "------------------------"
60 putStrLn (unpack (emitIniFile sampleConfig parseConfig))
60 putStr (unpack (emitIniFile sampleConfig configSpec))
6161 putStrLn "------------------------"
6262 putStrLn "\n"
6363 let p' = p { _confPort = 9191
6969 [ "value added by application" ]
7070 , updateIgnoreExtraneousFields = False
7171 }
72 let up = updateIniFile p' parseConfig example pol
72 let up = updateIniFile p' configSpec example pol
7373 case up of
7474 Left err -> putStrLn err
7575 Right up' -> do
7676 putStrLn "------------------------"
77 putStrLn (unpack up')
77 putStr (unpack up')
7878 putStrLn "------------------------"