diff options
author | Alan Pearce | 2024-05-14 21:16:23 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-14 21:45:02 +0200 |
commit | 1a5c82e2d08accb6330c4164ab987b87157b10ed (patch) | |
tree | 48d6a913809e60b1a0cc28a8b67413ffaf979f97 /searchix.go | |
parent | f08094f23aa4dc7d63a7c98b4429d88005fe3a2d (diff) | |
download | searchix-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.go | 8 |
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 { |