aboutsummaryrefslogtreecommitdiff
path: root/dirtyscripting.go
blob: 9924d548c35f26edc32abea316ea4b127f6c431e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)
  }
}