-
Notifications
You must be signed in to change notification settings - Fork 175
/
run.go
51 lines (40 loc) · 755 Bytes
/
run.go
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
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"strings"
)
var cmdRun = &Command{
Run: runRun,
Usage: "run [-e env] [-p port]",
Short: "Run a one-off command",
Long: `
Run a one-off command
Examples:
forego run bin/migrate
`,
}
var runEnvs envFiles
func init() {
cmdRun.Flag.Var(&runEnvs, "e", "env")
}
func runRun(cmd *Command, args []string) {
if len(args) < 1 {
cmd.printUsage()
os.Exit(1)
}
workDir, err := os.Getwd()
if err != nil {
handleError(err)
}
env, err := loadEnvs(runEnvs)
handleError(err)
const interactive = true
ps := NewProcess(workDir, strings.Join(args, " "), env, interactive)
ps.Stdin = os.Stdin
ps.Stdout = os.Stdout
ps.Stderr = os.Stderr
err = ps.Start()
handleError(err)
err = ps.Wait()
handleError(err)
}