-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRender.dhall
64 lines (56 loc) · 2.46 KB
/
Render.dhall
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
52
53
54
55
56
57
58
59
60
61
62
63
64
let Prelude/Text/concatSep =
https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Text/concatSep
let Next : Type = { next : Text }
let render/Builtin
: ./Builtin.dhall Text → Text
= λ(builtin : ./Builtin.dhall Text)
→ merge
{ CD =
λ(args : ./Builtin/Args/CD.dhall ⩓ Next)
→ "cd ${args.dir} ${args.next}"
, Export =
λ(args : ./Builtin/Args/Export.dhall ⩓ Next)
→ "export ${args.key} \"${args.value}\" ${args.next}"
, Unexport =
λ(args : ./Builtin/Args/Unexport.dhall ⩓ Next)
→ "unexport ${args.var} ${args.next}"
, FdClose =
λ(args : ./Builtin/Args/FdClose.dhall ⩓ Next)
→ "fdclose ${Natural/show args.fd} ${args.next}"
, FdBlock =
λ(args : ./Builtin/Args/FdBlock.dhall ⩓ Next)
→ "fdblock ${ if args.blocking
then ""
else "-n"} ${Natural/show args.fd} ${args.next}"
, FdMove =
λ(args : ./Builtin/Args/FdMove.dhall ⩓ Next)
→ "fdmove ${ if args.duplicate
then "-c"
else ""} ${Natural/show
args.fd-from} ${Natural/show
args.fd-to} ${args.next}"
, FdSwap =
λ(args : ./Builtin/Args/FdSwap.dhall ⩓ Next)
→ "fdswap ${Natural/show args.fd1} ${Natural/show
args.fd2} ${args.next}"
, FdReserve =
λ(args : ./Builtin/Args/FdReserve.dhall ⩓ Next)
→ "fdreserve ${Natural/show args.n} ${args.next}"
, Foreground =
λ(args : ./Builtin/Args/Foreground.dhall Text ⩓ Next)
→ "foreground { ${args.fg} } ${args.next}"
, Umask =
λ(args : ./Builtin/Args/Umask.dhall ⩓ Next)
→ "umask ${args.mask} ${args.next}"
, Exec =
λ(args : ./Builtin/Args/Exec.dhall)
→ "exec ${Prelude/Text/concatSep " " ([ args.cmd ] # args.argv)}"
, Exit =
λ(args : ./Builtin/Args/Exit.dhall)
→ "exit ${./ExitCode/Render.dhall args.exit-code}"
}
builtin
let render
: ./Instruction.dhall → Text
= λ(instruction : ./Instruction.dhall) → instruction Text render/Builtin
in render