1
0
forked from GitHub/gf-core
Files
gf-core/src/editor/simple/save.hs
hallgren e4e5ca23d3 gfse: initial support for grammars in the cloud
This lets the user access the same set of grammars from multiple devices.

Sharing grammars between multiple users is possible but discouraged at the
moment. There is no version handling, so concurrent editing of the same grammar
by different users might result in one user overwriting changes made by
another user. (The same goes for cuncurrent editing on multiple devices by
a single user, of course.)
2011-06-08 15:29:50 +00:00

17 lines
367 B
Haskell

import Monad(zipWithM)
import System(getArgs)
main = save =<< getArgs
save [dir] =
do fs@[ns,_] <- readIO =<< getContents
nes <- save_all fs
putStrLn $ unwords nes
where
save_all [ns,cs] = zipWithM write1 ns cs
write1 n c =
do writeFile (dir++"/"++ne) c
return ne
where
ne=if '.' `elem` n then n else n++".gf"