ChronoTomato/cmd/client/main.go
Sebastian Mark f54e8486f1 break: configure via file OR cli parameters
no more defaults when no parameter passed!
2024-10-27 22:33:36 +01:00

40 lines
1 KiB
Go

package client
import (
"atomicgo.dev/cursor"
"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"
)
func Start() {
cursor.Hide()
defer cursor.Show()
var config ChronoTomato.Config
channel := make(chan GoTomato.ServerMessage, 2)
parameter_url := flag.String("url", "", "GoTomato Server URL (eg ws://localhost:8080/ws)")
parameter_password := flag.String("password", "", "Control password for pomodoro session (optional)")
configfile := flag.String("config", "", "path to config file (optional)")
flag.Parse()
if *configfile != "" {
config = helper.ParseConfig(*configfile)
}
config.URL = *parameter_url
config.Password = *parameter_password
conn := websocket.Connect(config.URL)
go websocket.ProcessServerMessages(conn, channel)
frontend.Handler(conn, config, channel)
websocket.Disconnect(conn)
}