Created
June 2, 2025 00:36
-
-
Save crazymonkyyy/8834c6ddb5234e0ae0a9a3c9e145566a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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