From 6b382c55ed7885857a6232a0c8b086ab1f64985e Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 2 May 2017 20:37:39 +0200 Subject: move code out of main.go into the model types --- repo.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'repo.go') 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 +} -- cgit v1.3.1