about summary refs log tree commit diff stats
path: root/searchix.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-14 21:16:23 +0200
committerAlan Pearce2024-05-14 21:45:02 +0200
commit1a5c82e2d08accb6330c4164ab987b87157b10ed (patch)
tree48d6a913809e60b1a0cc28a8b67413ffaf979f97 /searchix.go
parentf08094f23aa4dc7d63a7c98b4429d88005fe3a2d (diff)
downloadsearchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.tar.lz
searchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.tar.zst
searchix-1a5c82e2d08accb6330c4164ab987b87157b10ed.zip
build: bake git hash into build for headers and --version
Diffstat (limited to 'searchix.go')
-rw-r--r--searchix.go8
1 files changed, 8 insertions, 0 deletions
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 {