fix: ide should inherit stdin/out/err
ci/woodpecker/push/goreleaser Pipeline was successful Details
ci/woodpecker/tag/goreleaser Pipeline was successful Details

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.5
jolheiser 2022-12-26 21:14:53 -06:00
parent 42853c9e12
commit b49dbe94b9
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 22 additions and 3 deletions

View File

@ -3,10 +3,10 @@ package cmd
import (
"context"
"flag"
"os/exec"
"github.com/AlecAivazis/survey/v2"
"github.com/peterbourgon/ff/v3/ffcli"
"os"
"os/exec"
)
func (h *Handler) IDE() *ffcli.Command {
@ -38,7 +38,26 @@ func (h *Handler) IDE() *ffcli.Command {
}
path := h.Config.WorkspaceBranch(branch)
return exec.Command("hx", path).Start()
cmd := exec.Command(getIDE(), path)
cmd.Dir = path
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
},
}
}
func getIDE() string {
for _, ide := range []string{
"hx",
"nvim",
"goland",
"vi",
} {
if i, err := exec.LookPath(ide); err == nil {
return i
}
}
return os.Getenv("EDITOR")
}