main.go 1.1 KB

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