blob: 6d4217fdda2360db604212db409c3c91d7fa76d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/usr/bin/env runhaskell
import System.Directory.Tree
import Data.List
main :: IO ()
main = readDirectory "." >>= putStrLn . genHostFile
genHostFile :: AnchoredDirTree String -> String
genHostFile (_ :/ (Dir _ contents)) = "{\n" ++ entries ++ "\n}\n"
where
entries = concatMap $ [genEntry name content | (File name content) <- contents]
genEntry fileName fileContent = unlines . indent $ [ "\"" ++ fileName ++ "\" = ''" ] ++ indent (lines fileContent) ++ [ "'';" ]
indent :: [String] -> [String]
indent = map (" " ++)
|