ChronoTomato/cmd/client/main.go

46 lines
1.1 KiB
Go
Raw Normal View History

2024-10-22 11:13:41 +00:00
package client
import (
"atomicgo.dev/cursor"
2024-10-22 11:13:41 +00:00
"flag"
"git.smsvc.net/pomodoro/ChronoTomato/internal/frontend"
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
2024-10-22 11:13:41 +00:00
)
var (
config ChronoTomato.Config
parameter_url = flag.String("url", "", "GoTomato Server URL (eg ws://localhost:8080/ws)")
parameter_password = flag.String("password", "", "Control password for pomodoro session")
configfile = flag.String("config", "", "Path to config file")
)
2024-10-22 11:13:41 +00:00
func Start() {
flag.Parse()
cursor.Hide()
defer cursor.Show()
// read cli parameters if no config file passed
if *configfile == "" {
config.URL = *parameter_url
config.Password = *parameter_password
} else {
// otherwise read config
config = helper.ParseConfig(*configfile)
}
conn := websocket.Connect(config.URL)
2024-10-22 11:13:41 +00:00
channel := make(chan GoTomato.ServerMessage)
go websocket.ProcessServerMessages(conn, channel)
frontend.UpdateLoop(conn, config, channel)
websocket.Disconnect(conn)
2024-10-22 11:13:41 +00:00
}