summaryrefslogtreecommitdiff
path: root/internal/editor/editor.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-02 11:41:44 +0300
committerPaul Buetow <paul@buetow.org>2026-05-02 11:41:55 +0300
commit266bedf71fe8a54b86af038889522a68bae562a8 (patch)
tree6ca2b100e63ea5b4e746e71b2b79b626ba70c597 /internal/editor/editor.go
parentd9184a5bfdc39d40232cb0d66a350daffcd7a326 (diff)
Drop hexai edit; document hexai config only.v0.38.4
The CLI now opens the config file only via hexai config (and --config). README, usage, and configuration docs describe the subcommand. Version 0.38.4. Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'internal/editor/editor.go')
-rw-r--r--internal/editor/editor.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/editor/editor.go b/internal/editor/editor.go
index a1af1be..722e336 100644
--- a/internal/editor/editor.go
+++ b/internal/editor/editor.go
@@ -68,3 +68,23 @@ func OpenTempAndEdit(initial []byte) (string, error) {
}
return strings.TrimSpace(string(b)), nil
}
+
+// OpenFile ensures the parent directory exists, then opens path in the editor
+// from Resolve() (HEXAI_EDITOR or EDITOR).
+func OpenFile(path string) error {
+ ed, err := Resolve()
+ if err != nil {
+ return err
+ }
+ path = filepath.Clean(strings.TrimSpace(path))
+ if path == "" || path == "." {
+ return errors.New("config path is empty")
+ }
+ dir := filepath.Dir(path)
+ if dir != "" && dir != "." {
+ if mkErr := os.MkdirAll(dir, 0o700); mkErr != nil {
+ return mkErr
+ }
+ }
+ return RunEditor(ed, path)
+}