add -s,--stdin parameter

This commit is contained in:
Jonas Forsberg 2022-04-27 13:48:34 +02:00
parent e58817937c
commit 238ea71762
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -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..] <Mesage>
-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 <message>
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"