Use os/exec to run editor

This commit is contained in:
Ken-Håvard Lieng 2015-05-25 05:15:32 +02:00
parent 61aa5880d3
commit 1f5dd7a5e0

View File

@ -5,7 +5,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"syscall"
"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/cobra" "github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/cobra"
@ -18,10 +17,13 @@ var (
configCmd = &cobra.Command{ configCmd = &cobra.Command{
Use: "config", Use: "config",
Short: "Edit config file", Short: "Edit config file",
Run: func(cmd *cobra.Command, _ []string) { Run: func(cmd *cobra.Command, args []string) {
if editor := findEditor(); editor != "" { if editor := findEditor(); editor != "" {
args := []string{editor, path.Join(storage.AppDir, "config.toml")} process := exec.Command(editor, path.Join(storage.AppDir, "config.toml"))
syscall.Exec(editor, args, os.Environ()) process.Stdin = os.Stdin
process.Stdout = os.Stdout
process.Stderr = os.Stderr
process.Run()
} else { } else {
log.Println("Unable to locate editor") log.Println("Unable to locate editor")
} }