~porcellis/t

ref: structure t/commands/write.go -rw-r--r-- 344 bytes
76f0d055 — Pedro Lucas Porcellis Generate a simple and nice doc 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package commands

import (
	"git.sr.ht/~porcellis/t/models"
	"os"
	"os/exec"
)

func Write(note models.Note) error {
	var (
		editor string
	)

	editor = os.Getenv("EDITOR")
	if editor == "" {
		editor = "vi"
	}

	cmd := exec.Command(editor, note.Path)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr

	return cmd.Run()
}