-
Notifications
You must be signed in to change notification settings - Fork 0
/
delo.pvd
71 lines (63 loc) · 1.93 KB
/
delo.pvd
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
65
66
67
68
69
70
71
shell = load stdlib/system/shell.py;
write = load stdlib/system/write.py;
read = load stdlib/system/read.py;
index = load stdlib/list/index.pvd;
slice = load stdlib/list/slice.pvd;
regex = load stdlib/string/regex.py;
replace = load stdlib/string/replace.py;
homedir = stdlib/system/homedir.py;
create path = shell (list "touch" path);
mkdir name = shell (list "mkdir" name);
build null = {
print "Error! it needs project path" new-line;
exit
};
build name = {
code = read (concat name "/src/main.pvd");
include = reduce (regex "load .*pvd;" code) @code lambda(i -> {
replace code i {
i = replace i "load " "";
i = replace i ";" "";
concat "{" (read (concat homedir "/" i)) "};"
}
});
output = concat "#!/usr/bin/env pravda" new-line ";" include;
mkdir (concat name "/build");
path = (concat name "/build/" name ".pvd");
create path; write path output;
};
run null = {
print "Error! it needs project path" new-line;
exit
};
run name = {
path = (concat "./" name "/build/" name ".pvd");
line1 = concat "chmod +x " path;
line2 = concat path " --args " ~(slice args (range 2 (len args)));
shell (concat line1 ";" line2);
};
init null = {
print "Error! it needs project name" new-line;
exit
};
init name = {
mkdir name;
mkdir (concat name "/src");
create (concat name "/src/main.pvd");
create (concat name "/README.md");
write (concat name "/src/main.pvd") (concat "print " double-quote "Hello, world!" double-quote " new-line" new-line);
write (concat name "/README.md") (concat "# " name new-line);
};
if (equal "new" (index args 0)) @{
init (index args 1);
} @{
if (equal "run" (index args 0)) @{
run (index args 1);
} @{
if (equal "build" (index args 0)) @{
build (index args 1);
} @{
print "Delo: the project manager of Pravda" new-line;
};
};
};