Fix Editor Command
This commit is contained in:
@@ -6,7 +6,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"git.bullercodeworks.com/brian/gime/cli"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -22,6 +25,23 @@ func init() {
|
||||
}
|
||||
|
||||
func opEditor(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("editor called")
|
||||
return nil
|
||||
p := cli.Program{}
|
||||
if err := p.Initialize(); err != nil {
|
||||
return err
|
||||
}
|
||||
file := p.GetTimerFilePath()
|
||||
if len(args) > 0 {
|
||||
if args[0] == "d" || args[0] == "done" {
|
||||
file = p.GetDoneFilePath()
|
||||
}
|
||||
}
|
||||
editor := os.Getenv("EDITOR")
|
||||
if editor == "" {
|
||||
return fmt.Errorf("No EDITOR set")
|
||||
}
|
||||
fmt.Println("Starting", editor, file)
|
||||
c := exec.Command(editor, file)
|
||||
c.Stdin = os.Stdin
|
||||
c.Stdout = os.Stdout
|
||||
return c.Run()
|
||||
}
|
||||
|
Reference in New Issue
Block a user