Add 'editor' op
This commit is contained in:
parent
4e4ef313f2
commit
53d0ec2550
@ -226,6 +226,10 @@ func (a *AppState) initialize() {
|
||||
[]string{"--h - Print this message"},
|
||||
a.opPrintUsage,
|
||||
)
|
||||
a.addOperation("editor",
|
||||
[]string{"editor - Open todo.txt file in your editor"},
|
||||
a.opEditor,
|
||||
)
|
||||
a.directory = a.config.Get("directory")
|
||||
a.fileTodo = a.config.Get("todofile")
|
||||
a.fileDone = a.config.Get("donefile")
|
||||
|
19
task_ops.go
19
task_ops.go
@ -2,12 +2,31 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
todotxt "git.bullercodeworks.com/brian/go-todotxt"
|
||||
)
|
||||
|
||||
func (a *AppState) opEditor(args []string) int {
|
||||
editor := os.Getenv("EDITOR")
|
||||
if editor == "" {
|
||||
fmt.Println("No EDITOR set")
|
||||
return 1
|
||||
}
|
||||
fmt.Println("Starting", editor, a.getTodoFile())
|
||||
c := exec.Command(editor, a.getTodoFile())
|
||||
c.Stdin = os.Stdin
|
||||
c.Stdout = os.Stdout
|
||||
if err := c.Run(); err != nil {
|
||||
fmt.Println(err)
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *AppState) opI3Status(args []string) int {
|
||||
var filterString string
|
||||
state := "Idle"
|
||||
|
Loading…
Reference in New Issue
Block a user