summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-07 18:05:43 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-07 18:05:43 +1000
commitf6a9c727faa06142208d8189441414b6bedb7b98 (patch)
tree69088ea883f0d133bb566e3e4ed95ed9553b4878 /main.go
parent9067c3be3ebb58d0ad25afa07d43e8941b087ac7 (diff)
run subprocess cleanly
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/main.go b/main.go
index b3586b04e..a0b87d716 100644
--- a/main.go
+++ b/main.go
@@ -1,19 +1,25 @@
package main
import (
+ "errors"
"flag"
"fmt"
"log"
"os"
+ "os/exec"
"os/user"
"time"
"github.com/fatih/color"
+ "github.com/jesseduffield/gocui"
)
+// ErrSubProcess is raised when we are running a subprocess
var (
- startTime time.Time
- debugging bool
+ startTime time.Time
+ debugging bool
+ ErrSubprocess = errors.New("running subprocess")
+ subprocess *exec.Cmd
)
func homeDirectory() string {
@@ -65,5 +71,15 @@ func main() {
startTime = time.Now()
verifyInGitRepo()
navigateToRepoRootDirectory()
- run()
+ for {
+ if err := run(); err != nil {
+ if err == gocui.ErrQuit {
+ break
+ } else if err == ErrSubprocess {
+ subprocess.Run()
+ } else {
+ log.Panicln(err)
+ }
+ }
+ }
}