This commit is contained in:
binwiederhier
2026-01-18 10:46:15 -05:00
parent 5a1aa68ead
commit 856f150958
9 changed files with 117 additions and 91 deletions

19
main.go
View File

@@ -2,12 +2,14 @@ package main
import (
"fmt"
"github.com/urfave/cli/v2"
"heckel.io/ntfy/v2/cmd"
"os"
"runtime"
"github.com/urfave/cli/v2"
"heckel.io/ntfy/v2/cmd"
)
// These variables are set during build time using -ldflags
var (
version = "dev"
commit = "unknown"
@@ -24,13 +26,24 @@ the Matrix room (https://matrix.to/#/#ntfy:matrix.org).
ntfy %s (%s), runtime %s, built at %s
Copyright (C) Philipp C. Heckel, licensed under Apache License 2.0 & GPLv2
`, version, commit[:7], runtime.Version(), date)
`, version, maybeShortCommit(commit), runtime.Version(), date)
app := cmd.New()
app.Version = version
app.Metadata = map[string]any{
cmd.MetadataKeyDate: date,
cmd.MetadataKeyCommit: commit,
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
func maybeShortCommit(commit string) string {
if len(commit) > 7 {
return commit[:7]
}
return commit
}