summaryrefslogtreecommitdiff
path: root/run.go
diff options
context:
space:
mode:
Diffstat (limited to 'run.go')
-rw-r--r--run.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/run.go b/run.go
index ac20c0a..be68eb8 100644
--- a/run.go
+++ b/run.go
@@ -68,3 +68,41 @@ func runStrict(wd string, cmd []string) {
log.Info(i, line)
}
}
+
+func runVerbose(wd string, cmd []string) error {
+ var err error
+ log.DaemonMode(true)
+ defer log.DaemonMode(false)
+ if wd != "" {
+ if err = os.Chdir(wd); err != nil {
+ return fmt.Errorf("cd %s failed %v", wd, err)
+ }
+ }
+ log.Info(wd, "running:", wd, cmd)
+ // result := shell.Run(cmd)
+ result := shell.Run(cmd)
+ if result.Error != nil {
+ log.Info("cmd failed", wd, cmd, err)
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ for i, line := range result.Stderr {
+ log.Info("STDERR:", i, line)
+ }
+ return result.Error
+ }
+ if result.Exit != 0 {
+ log.Info("cmd failed", wd, cmd, err)
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ for i, line := range result.Stderr {
+ log.Info("STDERR:", i, line)
+ }
+ return fmt.Errorf("cmd failed with %d", result.Exit)
+ }
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ return nil
+}