From 09d345073852138a202639e43a754e5611a67849 Mon Sep 17 00:00:00 2001 From: Justin Harms Date: Wed, 22 Jan 2025 17:32:30 -0600 Subject: [PATCH] feat: add version command to display application version --- .goreleaser.yaml | 16 +++++++++------- cmd/version.go | 23 +++++++++++++++++++++++ version/version.go | 3 +++ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 cmd/version.go create mode 100644 version/version.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9c7f3e4..141c4aa 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,13 +5,15 @@ before: - go mod tidy builds: -- env: - - CGO_ENABLED=0 - goos: - - linux - - windows - goarch: - - amd64 + - ldflags: + - -X s1d3sw1ped/SteamCache2/version.Version={{.Version}} + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + goarch: + - amd64 archives: - format: tar.gz diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..35af191 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "fmt" + "os" + "s1d3sw1ped/SteamCache2/version" + + "github.com/spf13/cobra" +) + +// versionCmd represents the version command +var versionCmd = &cobra.Command{ + Use: "version", + Short: "prints the version of SteamCache2", + Long: `Prints the version of SteamCache2. This command is useful for checking the version of the application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Fprintln(os.Stderr, "SteamCache2", version.Version) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +} diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..7f6928e --- /dev/null +++ b/version/version.go @@ -0,0 +1,3 @@ +package version + +var Version string