shell exec for 'forge commit'
This commit is contained in:
parent
d5f45aef13
commit
9f2ef46cd9
|
@ -0,0 +1,48 @@
|
||||||
|
package shell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Exec(args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errors.New("Error: Command slice is empty.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a long-running process, capture stdout and stderr
|
||||||
|
a, b := RemoveFirstElement(args)
|
||||||
|
|
||||||
|
process := exec.Command(a, b...)
|
||||||
|
process.Stderr = os.Stderr
|
||||||
|
process.Stdin = os.Stdin
|
||||||
|
process.Stdout = os.Stdout
|
||||||
|
process.Start()
|
||||||
|
err := process.Wait()
|
||||||
|
log.Log(INFO, "shell.Exec() err =", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExecCheck(args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errors.New("Error: Command slice is empty.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a long-running process, capture stdout and stderr
|
||||||
|
a, b := RemoveFirstElement(args)
|
||||||
|
|
||||||
|
process := exec.Command(a, b...)
|
||||||
|
process.Stderr = os.Stderr
|
||||||
|
process.Stdin = os.Stdin
|
||||||
|
process.Stdout = os.Stdout
|
||||||
|
err := process.Run()
|
||||||
|
if err != nil {
|
||||||
|
log.Info("ExecCheck() err", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info("ExecCheck() nil")
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in New Issue