diff options
| author | aarne <aarne@chalmers.se> | 2010-04-08 11:52:44 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2010-04-08 11:52:44 +0000 |
| commit | e98d1238f4615a14faae6f435527e19d0b8c96f4 (patch) | |
| tree | 2f15ba654d14723944f21fc9a14ea18c87f9e418 /examples/phrasebook/Update.hs | |
| parent | 242670a6cbdf32069b9876b50aadb67e468017ee (diff) | |
started a script and format for updating a set of gf files
Diffstat (limited to 'examples/phrasebook/Update.hs')
| -rw-r--r-- | examples/phrasebook/Update.hs | 23 |
1 files changed, 23 insertions, 0 deletions
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 |
