diff --git a/gemlog/write.go b/gemlog/write.go index 82d499c..ce7f19a 100644 --- a/gemlog/write.go +++ b/gemlog/write.go @@ -8,13 +8,21 @@ import ( tea "github.com/charmbracelet/bubbletea" ) -func WritePostCMD() tea.Msg { - id, err := write() - - if err != nil { - return ErrorMsg{err} +func WritePostCMD() tea.Cmd { + editor := os.Getenv("EDITOR") + if editor == "" { + editor = "vim" } - return Notification(fmt.Sprintf("Created post with id: %s", id)) + c := exec.Command(editor) //nolint:gosec + return tea.ExecProcess(c, func(err error) tea.Msg { + return Notification("Editor finished") + }) + // id, err := write() + + // if err != nil { + // return ErrorMsg{err} + // } + // return Notification(fmt.Sprintf("Created post with id: %s", id)) } // For messages that contain errors it's often handy to also implement the diff --git a/main.go b/main.go index dacd459..cc9f123 100644 --- a/main.go +++ b/main.go @@ -18,11 +18,11 @@ const ( ) func TODOCmd() tea.Msg { - return gemlog.Notification("This action has not been implemented yet.") + return gemlog.Notification("This action has not been implemented yet. Try another.") } var mainCommands = map[Action]tea.Cmd{ - Write: gemlog.WritePostCMD, + Write: gemlog.WritePostCMD(), Read: TODOCmd, Edit: TODOCmd, Delete: TODOCmd,