Repos / gorts / d626d2f627
commit d626d2f627aa71605039b1975eb74abbd32458bf
Author: Nhân <hi@imnhan.com>
Date: Thu Jun 22 17:47:25 2023 +0700
make tcl path configurable
diff --git a/main.go b/main.go
index 8b9992f..e4f9420 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@
"bufio"
_ "embed"
"encoding/json"
+ "flag"
"fmt"
"io"
"io/ioutil"
@@ -11,7 +12,6 @@
"net/http"
"os"
"os/exec"
- "runtime"
"strconv"
"strings"
"time"
@@ -43,15 +43,13 @@ func main() {
}
}()
- startGUI()
-}
+ tclPathPtr := flag.String("tcl", DefaultTclPath, "Path to tclsh executable")
+ flag.Parse()
-func startGUI() {
- tclPath := "tclsh"
- if runtime.GOOS == "windows" {
- tclPath = "./tclkit.exe"
- }
+ startGUI(*tclPathPtr)
+}
+func startGUI(tclPath string) {
cmd := exec.Command(tclPath, "-encoding", "utf-8")
stdout, err := cmd.StdoutPipe()
if err != nil {
diff --git a/hacks_linux.go b/main_linux.go
similarity index 72%
rename from hacks_linux.go
rename to main_linux.go
index e3d4782..cbdd98f 100644
--- a/hacks_linux.go
+++ b/main_linux.go
@@ -2,4 +2,6 @@
package main
+const DefaultTclPath = "tclsh"
+
func forceFocus(handle string) error { return nil }
diff --git a/hacks_windows.go b/main_windows.go
similarity index 90%
rename from hacks_windows.go
rename to main_windows.go
index 0adaf6f..b6154bf 100644
--- a/hacks_windows.go
+++ b/main_windows.go
@@ -9,6 +9,8 @@
"github.com/lxn/win"
)
+const DefaultTclPath = "./tclkit.exe"
+
func forceFocus(handle string) error {
hex := handle[2:] // trim the "0x" prefix
uintHandle, err := strconv.ParseUint(hex, 16, 64)