From f0d7dc80fc37510c053ee831cf756ce1404a52b3 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Sun, 27 Oct 2024 22:46:58 +0100 Subject: [PATCH] feat: update protocol version handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add ProtocolVersion variable to metadata package - don't set `ServerMessage.ProtocolVersion` in `main` - update `ServerMessage` default to include ProtocolVersion 🤖 --- cmd/server/main.go | 4 +--- internal/metadata/version.go | 3 +++ internal/shared/state.go | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 5d0b3a0..9f9db88 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -10,7 +10,6 @@ import ( "github.com/charmbracelet/log" "net/http" "os" - "strings" ) func Start() { @@ -21,10 +20,9 @@ func Start() { showVersionFlag := flag.Bool("version", false, "Output version") flag.Parse() - shared.Message.ProtocolVersion = strings.Split(metadata.GoTomatoVersion, ".")[0] if *showVersionFlag { fmt.Printf("App-Version: %s\n", metadata.GoTomatoVersion) - fmt.Printf("Protocol-Version: %s\n", shared.Message.ProtocolVersion) + fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion) os.Exit(0) } diff --git a/internal/metadata/version.go b/internal/metadata/version.go index d06d970..f1c52e1 100644 --- a/internal/metadata/version.go +++ b/internal/metadata/version.go @@ -1,3 +1,6 @@ package metadata +import "strings" + const GoTomatoVersion = "v0.0.4" // The GoTomato Version +var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] diff --git a/internal/shared/state.go b/internal/shared/state.go index 1f8c670..a9eac1b 100644 --- a/internal/shared/state.go +++ b/internal/shared/state.go @@ -1,16 +1,18 @@ package shared import ( + "git.smsvc.net/pomodoro/GoTomato/internal/metadata" "git.smsvc.net/pomodoro/GoTomato/pkg/models" ) var Message = models.ServerMessage{ - Mode: "Idle", - Settings: DefaultPomodoroConfig, - Session: 0, - TimeLeft: DefaultPomodoroConfig.Work, - Ongoing: false, - Paused: false, + Mode: "Idle", + Settings: DefaultPomodoroConfig, + Session: 0, + TimeLeft: DefaultPomodoroConfig.Work, + Ongoing: false, + Paused: false, + ProtocolVersion: metadata.ProtocolVersion, } var PomodoroPassword string