summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCastor Regex <[email protected]>2025-08-25 11:49:30 -0500
committerJeff Carr <[email protected]>2025-08-25 11:49:30 -0500
commit4f215037a1d89d638aed35ab6805b97128ba8876 (patch)
treeec4d751cee821970ce10191b7847977138525ea6
parentf5b923f18047646968389e60cf412486ba85bd9c (diff)
feat(editor): wait for ready file and rename to doEditor.go
-rw-r--r--doEditor.go (renamed from editor.go)30
1 files changed, 29 insertions, 1 deletions
diff --git a/editor.go b/doEditor.go
index 9186a16..e928f5a 100644
--- a/editor.go
+++ b/doEditor.go
@@ -5,9 +5,37 @@ import (
"os"
"os/exec"
"strings"
+ "time"
+
+ "go.wit.com/log"
)
-func doEditor() (string, error) {
+func doEditor() error {
+ for {
+ filename, err := doEditorOnce()
+ if err != nil {
+ return err
+ }
+ log.Info("filename:", filename)
+
+ for {
+ _, err := os.Stat("/tmp/regex.ready")
+ if err == nil {
+ break
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+ // read in regex.ready exists (should be SessionID)
+ // Println session ID
+ content, err := ioutil.ReadFile("/tmp/regex.ready")
+ if err != nil {
+ log.Error(err)
+ }
+ log.Infof("SessionID: %s", string(content))
+ }
+}
+
+func doEditorOnce() (string, error) {
// Create a temporary file
tmpfile, err := ioutil.TempFile("", "regex-*.txt")
if err != nil {