error if empty editor

This commit is contained in:
Lilian Jónsdóttir 2024-04-03 17:10:37 -07:00
parent c4ee8e7b04
commit b18ea5ff7b

View file

@ -1,6 +1,7 @@
package editor package editor
import ( import (
"fmt"
"io/fs" "io/fs"
"os" "os"
"os/exec" "os/exec"
@ -18,6 +19,10 @@ type Editor struct {
func (e *Editor) EditFile(filename string) error { func (e *Editor) EditFile(filename string) error {
args := append(e.Args, filename) args := append(e.Args, filename)
if e.Command == "" {
return fmt.Errorf("no editor set or detected")
}
cmd := exec.Command(e.Command, args...) cmd := exec.Command(e.Command, args...)
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout