Add --version / version with baked-in git commit

ldflags inject version, commit, and build date; a version subcommand
also reports go version and platform. Ends the which-binary-is-this
guessing after deploys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Woodard
2026-07-01 19:47:44 -05:00
parent eb05c48db8
commit 477246d574
3 changed files with 34 additions and 1 deletions

View File

@@ -17,10 +17,18 @@ var (
logLevel string
)
// Build metadata, injected via -ldflags -X at build time (see Makefile).
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
root := &cobra.Command{
Use: "rtsp-streamer",
Short: "Full-screen RTSP camera wall for UniFi Protect",
Version: fmt.Sprintf("%s (commit %s, built %s)", version, commit, date),
SilenceUsage: true,
SilenceErrors: true,
}
@@ -34,6 +42,7 @@ func main() {
statusCmd(),
tuiCmd(),
configCmd(),
versionCmd(),
)
if err := root.Execute(); err != nil {