forked from GitHub/gf-core
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.)
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import Monad(zipWithM_)
|
||||
import Monad(zipWithM)
|
||||
import System(getArgs)
|
||||
|
||||
main = save =<< getArgs
|
||||
|
||||
save [dir] =
|
||||
do fs@[ns,_] <- readIO =<< getContents
|
||||
save_all fs
|
||||
putStrLn $ unwords [n++".gf"|n<-ns]
|
||||
nes <- save_all fs
|
||||
putStrLn $ unwords nes
|
||||
where
|
||||
save_all [ns,cs] = zipWithM_ write1 ns cs
|
||||
write1 n = writeFile (dir++"/"++n++".gf")
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user