-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFileTree.hs
51 lines (42 loc) · 1.29 KB
/
FileTree.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Hemmet.FileTree
( FileTreeBackend
, FileTreeRunner
, fileTree
, bashScript
, treeLike
) where
import Data.Text as T
import Hemmet.Backend
import Hemmet.Runner
import Hemmet.FileTree.Rendering
import Hemmet.FileTree.Template
import Hemmet.FileTree.Transformation
import Hemmet.FileTree.Tree
type FileTreeBackend = Backend FileTreePayload
type FileTreeRunner = Runner FileTreePayload
fileTree :: FileTreeBackend
fileTree = Backend
{ getTransformation = get
, parser = template
, examples = fileTreeExamples
}
where
get input
| "|hs|" `isPrefixOf` input = (haskellify, T.drop 4 input)
| "|py|" `isPrefixOf` input = (pythonify, T.drop 4 input)
| otherwise = (id, input)
bashScript :: FileTreeRunner
bashScript = PureRunner renderBashScript
treeLike :: FileTreeRunner
treeLike = PureRunner renderTreeLike
fileTreeExamples :: [(Text, Text)]
fileTreeExamples =
[ ("simple", "file")
, ( "complex"
, "file1 folderA/{fileA1 folderAA/ folderAB/{fileAB1 fileAB2} fileA2}\
\ folderB/folderBA/folderBAA/fileBAA1 file2"
)
, ("ordering", "c aa b cc a bb")
, ("transformation: Haskell project", "|hs|app/main src/!lib/{types utils}")
, ("transformation: Python project", "|py|src/package/{foo bar} test/package")
]