summaryrefslogtreecommitdiff
path: root/dirtyscripting.go
diff options
context:
space:
mode:
Diffstat (limited to 'dirtyscripting.go')
-rw-r--r--dirtyscripting.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/dirtyscripting.go b/dirtyscripting.go
new file mode 100644
index 0000000..9924d54
--- /dev/null
+++ b/dirtyscripting.go
@@ -0,0 +1,42 @@
+package planr
+
+import (
+ "io"
+ "os"
+ "os/exec"
+ "log"
+)
+
+func RunCmd(name string, args ...string) {
+ cmd := exec.Command(name, args...)
+
+ stderr, err := cmd.StderrPipe()
+ if err != nil {
+ log.Fatal(err);
+ }
+
+ stdout, err := cmd.StdoutPipe()
+ if err != nil {
+ log.Fatal(err);
+ }
+
+ go func() {
+ io.Copy(os.Stderr, stderr)
+ }()
+
+ go func() {
+ io.Copy(os.Stdout, stdout)
+ }()
+
+ if err := cmd.Start(); err != nil {
+ log.Fatal(err)
+ }
+
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ if err := cmd.Wait(); err != nil {
+ log.Fatalf("Could not execute cmake command\n%v", err)
+ }
+}