Skip to content

Instantly share code, notes, and snippets.

@crazymonkyyy
Created June 2, 2025 00:36
Show Gist options
  • Save crazymonkyyy/8834c6ddb5234e0ae0a9a3c9e145566a to your computer and use it in GitHub Desktop.
Save crazymonkyyy/8834c6ddb5234e0ae0a9a3c9e145566a to your computer and use it in GitHub Desktop.
/*
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 exe(string s)=>executeShell(s).output.writeln;
void main(string[] args){
assert(args.length>1,"gib file");
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment