From 1ddc49a1e54448f4308a71eb8da0d8a7f34d2015 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Sun, 7 May 2023 11:39:21 -0400 Subject: [PATCH] allow to pass the token via env var GOTIFY_TOKEN Passing the token as an argument has the implication that the token will show up in the process list. To solve this issue an environment variable `GOTIFY_TOKEN` can be used to pass the token to gotify. Example: ``` GOTIFY_TOKEN=app_token_here MSG="Test message" gotify push $MSG ``` --- README.md | 4 ++-- command/push.go | 2 +- command/watch.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c653b0b..8d59c03 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ OPTIONS: --priority value, -p value Set the priority (default: 0) --exec value, -x value Pass command to exec (default: "sh -c") --title value, -t value Set the title (empty for command) - --token value Override the app token + --token value Override the app token [$GOTIFY_TOKEN] --url value Override the Gotify URL --output value, -o value Output verbosity (short|default|long) (default: "default") ``` @@ -163,7 +163,7 @@ DESCRIPTION: OPTIONS: --priority value, -p value Set the priority (default: 0) --title value, -t value Set the title (empty for app name) - --token value Override the app token + --token value Override the app token [$GOTIFY_TOKEN] --url value Override the Gotify URL --quiet, -q Do not output anything (on success) --contentType value The content type of the message. See https://gotify.net/docs/msgextras#client-display diff --git a/command/push.go b/command/push.go index ae9f466..22a9296 100644 --- a/command/push.go +++ b/command/push.go @@ -25,7 +25,7 @@ func Push() cli.Command { Flags: []cli.Flag{ cli.IntFlag{Name: "priority,p", Usage: "Set the priority"}, cli.StringFlag{Name: "title,t", Usage: "Set the title (empty for app name)"}, - cli.StringFlag{Name: "token", Usage: "Override the app token"}, + cli.StringFlag{Name: "token", Usage: "Override the app token", EnvVar: "GOTIFY_TOKEN"}, cli.StringFlag{Name: "url", Usage: "Override the Gotify URL"}, cli.BoolFlag{Name: "quiet,q", Usage: "Do not output anything (on success)"}, cli.StringFlag{Name: "contentType", Usage: "The content type of the message. See https://gotify.net/docs/msgextras#client-display"}, diff --git a/command/watch.go b/command/watch.go index e2cd047..f0ee519 100644 --- a/command/watch.go +++ b/command/watch.go @@ -25,7 +25,7 @@ func Watch() cli.Command { cli.IntFlag{Name: "priority,p", Usage: "Set the priority"}, cli.StringFlag{Name: "exec,x", Usage: "Pass command to exec", Value: "sh -c"}, cli.StringFlag{Name: "title,t", Usage: "Set the title (empty for command)"}, - cli.StringFlag{Name: "token", Usage: "Override the app token"}, + cli.StringFlag{Name: "token", Usage: "Override the app token", EnvVar: "GOTIFY_TOKEN"}, cli.StringFlag{Name: "url", Usage: "Override the Gotify URL"}, cli.StringFlag{Name: "output,o", Usage: "Output verbosity (short|default|long)", Value: "default"}, },