-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
adr wants to make the compiler have a repl mode but for reasons I dont actually understand somethings blocking it
when I was looking into file watching I made a trivial one
this is slow, but not as slow as dlang.io and it also support har
/*
repl
run dlang.io like gists
the `--- foo.d` thing
*/
import std;
enum tempfolder=".__gist/";
auto dropmap(alias F,R)(R r,int i){
foreach(j;0..i){
F(r.front);
r.popFront;
}
return r;
}
void watchfile(F)(string file, F func){
import arsd.core;
auto w = new DirectoryWatcher(FilePath("."),file,false,(path, op) {
if(path.path==file){
func();
}});
getThisThreadEventLoop().run(() => false);
}
void exe(string s)=>executeShell(s).output.writeln;
void main(string[] args){
assert(args.length>1,"gib file");
watchfile(args[1],(){
File temp;
string command;
exe("mkdir "~tempfolder);
foreach(l;File(args[1]).byLine.dropmap!((s){command=s.dup;})(1)){
if(l.length>3 && l[0..3]=="---"){
//"opening:".writeln(l);
temp=File((tempfolder~l[3..$].strip).to!string,"w");
} else {
temp.writeln(l);
}
}
temp.close;
exe("cd "~tempfolder~";"~command);
exe("rm -rf "~tempfolder);
});
}
If that isnt happening soon Id just ship this
Metadata
Metadata
Assignees
Labels
No labels