aboutsummaryrefslogtreecommitdiff
path: root/repo.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2017-05-02 20:37:39 +0200
committerStefan Majewsky <majewsky@gmx.net>2017-05-02 20:37:39 +0200
commit6b382c55ed7885857a6232a0c8b086ab1f64985e (patch)
tree7a7bda45f42ab4040e4a4104a0cc5157e984204b /repo.go
parentba69181d4d892aecfc35f9f30fe190d946662284 (diff)
downloadgofu-6b382c55ed7885857a6232a0c8b086ab1f64985e.tar.gz
move code out of main.go into the model types
Diffstat (limited to 'repo.go')
-rw-r--r--repo.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/repo.go b/repo.go
index f0c2491..532b5d1 100644
--- a/repo.go
+++ b/repo.go
@@ -178,3 +178,19 @@ func (r Repo) Checkout() error {
return nil
}
+
+//InteractiveExec implements the meat of the `rtree exec` command. It returns
+//true iff the command exited successfully.
+func (r Repo) InteractiveExec(command string, args ...string) (ok bool) {
+ fmt.Fprintf(os.Stdout, "\x1B[1;36m>> \x1B[0;36m%s\x1B[0m\n", r.AbsolutePath())
+ cmd := exec.Command(command, args...)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ cmd.Dir = r.AbsolutePath()
+ err := cmd.Run()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "\x1B[1;31m!! \x1B[0;31m%s\x1B[0m\n", err.Error())
+ return false
+ }
+ return true
+}