From e98d1238f4615a14faae6f435527e19d0b8c96f4 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 8 Apr 2010 11:52:44 +0000 Subject: started a script and format for updating a set of gf files --- examples/phrasebook/Update.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/phrasebook/Update.hs (limited to 'examples/phrasebook/Update.hs') diff --git a/examples/phrasebook/Update.hs b/examples/phrasebook/Update.hs new file mode 100644 index 000000000..1e7cf2578 --- /dev/null +++ b/examples/phrasebook/Update.hs @@ -0,0 +1,23 @@ +import System + +main = do + file:_ <- getArgs + updates <- readFile file >= return . readUpdates + mapM_ (doUpdate file) updates + return () + +type Update = (FilePath, [String]) + +readUpdates :: String -> [Update] +readUpdates s = [] + +doUpdate :: FilePath -> Update -> IO () +doUpdate src (target,ls) = do + s <- readFile target + let beg = dropLastBracket s + let tmp = tmpFile target + writeFile tmp beg + appendFile tmp $ unlines [(line ++ "-- UPDATE FROM " ++ src) | line <- ls] + appendFile tmp "\n}\n" + +dropLastBracket s = s -- cgit v1.2.3