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