-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
Prio.3.NormalA bug that is neither a blocker nor a regressionA bug that is neither a blocker nor a regressionType.EnhancementAn improvement to an existing functionalityAn improvement to an existing functionality
Description
I offered this code to opend; it would need adr's code to compile here(or shipping a file watching method in Phobos), but for parity you can have it as well
/*
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);
});
}
Metadata
Metadata
Assignees
Labels
Prio.3.NormalA bug that is neither a blocker nor a regressionA bug that is neither a blocker nor a regressionType.EnhancementAn improvement to an existing functionalityAn improvement to an existing functionality