Fix Editor Command
This commit is contained in:
parent
45d13e7052
commit
b0f5e928d9
@ -27,6 +27,10 @@ func (p *Program) Initialize() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Program) GetTimerFilePath() string {
|
||||
return p.timerPath
|
||||
}
|
||||
|
||||
func (p *Program) LoadTimerList() error {
|
||||
var err error
|
||||
var tl timertxt.TimerList
|
||||
@ -43,6 +47,10 @@ func (p *Program) WriteTimerList() error {
|
||||
return p.TimerList.WriteToFilename(p.timerPath)
|
||||
}
|
||||
|
||||
func (p *Program) GetDoneFilePath() string {
|
||||
return p.donePath
|
||||
}
|
||||
|
||||
func (p *Program) LoadDoneList() error {
|
||||
var err error
|
||||
var tl timertxt.TimerList
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user