From aa6cb93e98c69b935409b6daf052edb2d514a380 Mon Sep 17 00:00:00 2001 From: birdhimself Date: Sat, 18 Apr 2026 01:19:39 +0200 Subject: [PATCH] feat: display version information at program start The Go linker will inject version information either from the tag (if HEAD points to a tag) or from the commit hash. --- Makefile | 9 +++++++-- cmd/compatdata-humanizer/compatdata-humanizer.go | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ea6a51c..129290e 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ INSTALL_DIR = $(HOME)/.local/bin BINARY = compatdata-humanizer +VERSION := $(shell git tag --points-at HEAD | grep . || git rev-parse --short=8 HEAD) build: - go build -ldflags "-s" -o $(BINARY) ./cmd/compatdata-humanizer/compatdata-humanizer.go + go build \ + -ldflags "-s -X main.version=$(VERSION)" -o $(BINARY) \ + ./cmd/compatdata-humanizer/compatdata-humanizer.go run: - go run ./cmd/compatdata-humanizer/compatdata-humanizer.go + go run \ + -ldflags "-X main.version=$(VERSION)" \ + ./cmd/compatdata-humanizer/compatdata-humanizer.go install: build cp $(BINARY) "$(INSTALL_DIR)" diff --git a/cmd/compatdata-humanizer/compatdata-humanizer.go b/cmd/compatdata-humanizer/compatdata-humanizer.go index 475b101..d10412c 100644 --- a/cmd/compatdata-humanizer/compatdata-humanizer.go +++ b/cmd/compatdata-humanizer/compatdata-humanizer.go @@ -13,7 +13,12 @@ import ( "github.com/birdhimself/compatdata-humanizer/internal/writer" ) +var version string + func main() { + cli.Title("Compatdata Humanizer") + cli.Info("Version %s", version) + _ = config.Get() libFiles, err := steam.LibraryFiles()