mirror of
https://github.com/nikdoof/hapz2m.git
synced 2026-01-30 15:08:19 +00:00
Add version info to help output
This commit is contained in:
@@ -12,7 +12,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime/debug"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,7 +67,40 @@ func parseConfig(fname string) (cfg *config, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readVcsRevision() string {
|
||||||
|
ver := ""
|
||||||
|
dirty := false
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, s := range info.Settings {
|
||||||
|
switch s.Key {
|
||||||
|
case "vcs.revision":
|
||||||
|
if len(s.Value) >= 8 {
|
||||||
|
ver = s.Value[:8]
|
||||||
|
} else {
|
||||||
|
ver = s.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
case "vcs.modified":
|
||||||
|
dirty = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dirty {
|
||||||
|
ver += "-dirty"
|
||||||
|
}
|
||||||
|
return ver
|
||||||
|
}
|
||||||
|
return "?"
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Usage = func() {
|
||||||
|
fmt.Fprintf(flag.CommandLine.Output(), "hapz2m version %s\n"+
|
||||||
|
"HomeKit <-> zigbee2mqtt Bridge\n"+
|
||||||
|
"\nUsage: %s [options...]\n",
|
||||||
|
readVcsRevision(), filepath.Base(os.Args[0]))
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// check if we are running under systemd, and if so, dont output timestamps
|
// check if we are running under systemd, and if so, dont output timestamps
|
||||||
|
|||||||
Reference in New Issue
Block a user