From 238ea71762112afcaeb30d16984bae0a6046484d Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Wed, 27 Apr 2022 13:48:34 +0200 Subject: [PATCH] add -s,--stdin parameter --- bin/gotify | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/gotify b/bin/gotify index 32a0a79..fa9e481 100755 --- a/bin/gotify +++ b/bin/gotify @@ -3,6 +3,7 @@ set -aeou pipefail GOTIFY_CLI_CONFIG_FILE="${GOTIFY_CLI_CONFIG_FILE-"$HOME/.gotify.sh"}" +GOTIFY_STDIN=false function printHelp(){ @@ -13,6 +14,7 @@ Usage ${0##*/} [options..] -p,--priority Set priority of the message -T,--token Specify gotify app token -b,--bash-completion Print out bash completion and exit +-s, --stdin Read STDIN instead of taking EOF } @@ -82,6 +84,9 @@ while :; do GOTIFY_URL="$2" shift ;; + -s|--stdin) + GOTIFY_STDIN=true + ;; -b|--bash-completion) print_bash_completion exit 0 @@ -100,11 +105,14 @@ while :; do shift done - -if [[ -z "${1-}" ]]; then +if $GOTIFY_STDIN; then + read -r MESSAGE +elif [[ -z "${1-}" ]]; then printf "ERROR: No message to send\n" >&2 printHelp exit 2 +else + MESSAGE="$1" fi -sendMessage "${1-}" +sendMessage "$MESSAGE"