add svn_runner module

This commit is contained in:
josh committed 2020-01-07 15:59:31 -05:00
1 parent bb20d3bf38
commit 8b85b70ea9
4 files changed
+56 -1

No files matched your search

+2 -1
View File
@@ -1,2 +1,3 @@
/Build/
/.rscons*
/build/
/svi
+10
View File
@@ -0,0 +1,10 @@
configure do
check_d_compiler
end
build do
Environment.new do |env|
env["D_IMPORT_PATH"] << "src"
env.Program("svi", glob("src/**/*.d"))
end
end
+8
View File
@@ -0,0 +1,8 @@
import svn_runner;
import std.stdio;
int main(string[] args)
{
auto r = run_svn(["ls", "https://vcs.gentex.com/svn/embedded_sw"]);
return 0;
}
+36
View File
@@ -0,0 +1,36 @@
import std.process;
import std.stdio;
struct Result
{
int status;
char[] stdout;
char[] stderr;
}
private File nullfd()
{
return File("/dev/null", "r");
}
Result run_svn(string[] args)
{
string[] command = ["svn", "--non-interactive", "--no-auth-cache"] ~ args;
auto stdout_pipe = pipe();
auto stderr_pipe = pipe();
auto pid = spawnProcess(command, nullfd(), stdout_pipe.writeEnd,
stderr_pipe.writeEnd);
char[] stdout;
char[] stderr;
char[] buf;
while (stdout_pipe.readEnd.readln(buf))
{
stdout ~= buf;
}
while (stderr_pipe.readEnd.readln(buf))
{
stderr ~= buf;
}
int status = wait(pid);
return Result(status, stdout, stderr);
}