Separate ExecSystem into ExecSystemFull and ExecSystenErr
This commit is contained in:
parent
624f26fbf5
commit
5578be58f5
1 changed files with 16 additions and 12 deletions
28
main.go
28
main.go
|
@ -11,9 +11,8 @@ import (
|
|||
var verbosePtr = flag.Bool("v", false, "boolean")
|
||||
|
||||
|
||||
func ExecSystem(command string) {
|
||||
func ExecSystemFull(command string) {
|
||||
|
||||
if *verbosePtr{
|
||||
cmd := exec.Command("/usr/bin/bash", "-c", command)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
|
@ -44,7 +43,8 @@ func ExecSystem(command string) {
|
|||
for stderrScanner.Scan() {
|
||||
fmt.Println(stderrScanner.Text())
|
||||
}
|
||||
} else {
|
||||
}
|
||||
func ExecSystemErr(command string) {
|
||||
cmd := exec.Command("/usr/bin/bash", "-c", command)
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
|
@ -65,7 +65,7 @@ func ExecSystem(command string) {
|
|||
fmt.Println(stderrScanner.Text())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func main() {
|
||||
|
@ -87,8 +87,9 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
os.Chdir(workDir)
|
||||
fmt.Println("Running docker compose up -d in", workDir)
|
||||
ExecSystem("docker compose up -d")
|
||||
fmt.Println("[1] Running docker compose up -d in", workDir)
|
||||
ExecSystemErr("docker compose up -d")
|
||||
ExecSystemFull("docker compose ps")
|
||||
}
|
||||
|
||||
if len(os.Args) == 2 {
|
||||
|
@ -102,16 +103,18 @@ func main() {
|
|||
}
|
||||
|
||||
os.Chdir(workDir)
|
||||
fmt.Println("Running docker compose up -d in", workDir)
|
||||
ExecSystem("docker compose up -d")
|
||||
fmt.Println("[2v] Running docker compose up -d in", workDir)
|
||||
ExecSystemFull("docker compose up -d")
|
||||
ExecSystemFull("docker compose ps")
|
||||
} else {
|
||||
// ./compose-runner /path should run docker compose up -d in /path
|
||||
|
||||
workDir := os.Args[1]
|
||||
|
||||
os.Chdir(workDir)
|
||||
fmt.Println("Running docker compose up -d in", workDir)
|
||||
ExecSystem("docker compose up -d")
|
||||
fmt.Println("[2] Running docker compose up -d in", workDir)
|
||||
ExecSystemErr("docker compose up -d")
|
||||
ExecSystemFull("docker compose ps")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,8 +122,9 @@ func main() {
|
|||
if len(os.Args) == 3 {
|
||||
workDir := os.Args[2]
|
||||
os.Chdir(workDir)
|
||||
fmt.Println("Running docker compose up -d in", workDir)
|
||||
ExecSystem("docker compose up -d")
|
||||
fmt.Println("[3] Running docker compose up -d in", workDir)
|
||||
ExecSystemFull("docker compose up -d")
|
||||
ExecSystemFull("docker compose ps")
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue