No terminal window on windows

This commit is contained in:
2026-02-13 20:59:47 +01:00
parent a9e626393c
commit 8e369ebd5a
5 changed files with 201 additions and 4 deletions

53
main.go
View File

@@ -21,6 +21,7 @@ import (
"luxtools-client/internal/config"
"luxtools-client/internal/installer"
"luxtools-client/internal/logging"
"luxtools-client/internal/notify"
"luxtools-client/internal/openfolder"
"luxtools-client/internal/web"
@@ -129,8 +130,8 @@ func buildInfoPayload() map[string]any {
}
func main() {
infoLog := log.New(os.Stdout, "", log.LstdFlags)
errLog := log.New(os.Stderr, "ERROR: ", log.LstdFlags)
infoLog, errLog, logStore, logPath, cleanup := logging.Setup()
defer cleanup()
if len(os.Args) > 1 {
switch os.Args[1] {
@@ -232,6 +233,54 @@ func main() {
}
})
register(mux, &endpointDocs, "/control", "GET, OPTIONS", "Logs control page", func(w http.ResponseWriter, r *http.Request) {
withCORS(w, r)
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
if r.Method != http.MethodGet {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
displayPath := logPath
if displayPath == "" {
displayPath = "unavailable"
}
data := struct {
LogPath string
LogText template.HTML
Updated string
}{
LogPath: displayPath,
LogText: template.HTML(html.EscapeString(string(logStore.Bytes()))),
Updated: time.Now().Format(time.RFC3339),
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := web.RenderLogs(w, data); err != nil {
errLog.Printf("/control template error=%v", err)
}
})
register(mux, &endpointDocs, "/logs", "GET, OPTIONS", "Recent log output (text)", func(w http.ResponseWriter, r *http.Request) {
withCORS(w, r)
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusNoContent)
return
}
if r.Method != http.MethodGet {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("Cache-Control", "no-store")
_, _ = w.Write(logStore.Bytes())
})
register(mux, &endpointDocs, "/settings/config", "GET, POST, PUT, OPTIONS", "Read/update path alias config (JSON)", func(w http.ResponseWriter, r *http.Request) {
withCORS(w, r)
if r.Method == http.MethodOptions {