From 1a5c82e2d08accb6330c4164ab987b87157b10ed Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 14 May 2024 21:16:23 +0200 Subject: build: bake git hash into build for headers and --version --- searchix.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'searchix.go') diff --git a/searchix.go b/searchix.go index 217dc1a..79940e9 100644 --- a/searchix.go +++ b/searchix.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "log/slog" "os" @@ -17,10 +18,13 @@ import ( "github.com/pelletier/go-toml/v2" ) +var buildVersion string + var ( configFile = flag.String("config", "config.toml", "config `file` to use") liveReload = flag.Bool("live", false, "whether to enable live reloading (development)") replace = flag.Bool("replace", false, "whether to replace existing database, if it exists") + version = flag.Bool("version", false, "print version information") ) func nextOccurrenceOfLocalTime(t toml.LocalTime) time.Time { @@ -45,6 +49,10 @@ func nextOccurrenceOfLocalTime(t toml.LocalTime) time.Time { func main() { flag.Parse() + if *version { + fmt.Fprintln(os.Stderr, "searchix", buildVersion, config.CommitSHA) + os.Exit(0) + } conf, err := config.GetConfig(*configFile) if err != nil { -- cgit 1.4.1