main.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "runtime"
  6. "github.com/urfave/cli/v2"
  7. "heckel.io/ntfy/v2/cmd"
  8. )
  9. // These variables are set during build time using -ldflags
  10. var (
  11. version = "dev"
  12. commit = "unknown"
  13. date = "unknown"
  14. )
  15. func main() {
  16. cli.AppHelpTemplate += fmt.Sprintf(`
  17. Try 'ntfy COMMAND --help' or https://ntfy.sh/docs/ for more information.
  18. To report a bug, open an issue on GitHub: https://github.com/binwiederhier/ntfy/issues.
  19. If you want to chat, simply join the Discord server (https://discord.gg/cT7ECsZj9w), or
  20. the Matrix room (https://matrix.to/#/#ntfy:matrix.org).
  21. ntfy %s (%s), runtime %s, built at %s
  22. Copyright (C) Philipp C. Heckel, licensed under Apache License 2.0 & GPLv2
  23. `, version, maybeShortCommit(commit), runtime.Version(), date)
  24. app := cmd.New()
  25. app.Version = version
  26. app.Metadata = map[string]any{
  27. cmd.MetadataKeyDate: date,
  28. cmd.MetadataKeyCommit: commit,
  29. }
  30. if err := app.Run(os.Args); err != nil {
  31. fmt.Fprintln(os.Stderr, err.Error())
  32. os.Exit(1)
  33. }
  34. }
  35. func maybeShortCommit(commit string) string {
  36. if len(commit) > 7 {
  37. return commit[:7]
  38. }
  39. return commit
  40. }