From 169d2127da971b1f665c79347cd3a59ba5ce425f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 8 Nov 2024 06:41:47 -0600 Subject: [PATCH] use go-cmd/cmd --- repoview.go | 2 +- shell.go | 32 +++++++++++++------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/repoview.go b/repoview.go index e56c537..d1531ef 100644 --- a/repoview.go +++ b/repoview.go @@ -122,7 +122,7 @@ func (r *repoWindow) repoMenu() *gui.Node { r.Disable() defer r.Enable() for _, repo := range r.View.AllRepos() { - repo.RunCmd([]string{"git", "pull"}) + repo.Run([]string{"git", "pull"}) } }) diff --git a/shell.go b/shell.go index 3d0b211..42c412e 100644 --- a/shell.go +++ b/shell.go @@ -1,21 +1,14 @@ package main import ( - "go.wit.com/log" + "strings" - "go.wit.com/lib/gui/repostatus" + "go.wit.com/log" + "go.wit.com/lib/gui/shell" ) // only errors on bad errors func quickCmd(fullpath string, cmd []string) bool { - var err error - var b bool - var output string - - // if me.autoWorkingPwd.String() != fullpath { - // me.autoWorkingPwd.SetValue(fullpath) - // } - if me.autoDryRun.Checked() { log.Warn("RUN --dry-run", fullpath, cmd) return false @@ -23,18 +16,19 @@ func quickCmd(fullpath string, cmd []string) bool { log.Warn("RUN:", fullpath, cmd) } - err, b, output = repostatus.RunCmd(fullpath, cmd) - if err != nil { + r := shell.PathRun(fullpath, cmd) + output := strings.TrimSpace(strings.Join(r.Stdout, "\n")) + if r.Error != nil { log.Warn("cmd =", cmd) - log.Warn("err =", err) - log.Warn("b =", b) - log.Warn("output =", string(output)) + log.Warn("err =", r.Error) + log.Warn("b =", r.Exit) + log.Warn("output =", output) return false - } else if !b { - log.Warn("b =", b) - log.Warn("output =", string(output)) + } else if r.Exit != 0 { + log.Warn("b =", r.Exit) + log.Warn("output =", output) return true } - log.Warn("output = ", string(output)) + log.Warn("output = ", output) return true }