diff options
| author | eltrac <hi@eltr.ac> | 2026-03-04 10:44:03 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-03-04 10:44:03 +0800 |
| commit | bcad5fc9583cde2c462a85ddff9601183b97e4ff (patch) | |
| tree | 1197947e383a1b91e6587cbc2c71d3c4ea7f4b82 /utilities.go | |
| parent | 40b092db68f5909f2a1121369b6c11d2d15b9e88 (diff) | |
refactor: divide main.go into modules
Diffstat (limited to 'utilities.go')
| -rw-r--r-- | utilities.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/utilities.go b/utilities.go new file mode 100644 index 0000000..5a9b69f --- /dev/null +++ b/utilities.go @@ -0,0 +1,22 @@ +package main + +import ( + "os" + "os/exec" + + tea "charm.land/bubbletea/v2" +) + +type editorFinishedMsg struct { + err error +} + +func openEditor(path string) tea.Cmd { + editor := os.Getenv("EDITOR") + if editor == "" { + editor = "vim" + } + return tea.ExecProcess(exec.Command(editor, path), func(err error) tea.Msg { + return editorFinishedMsg{err: err} + }) +} |
