add -s,--stdin parameter
This commit is contained in:
parent
e58817937c
commit
238ea71762
14
bin/gotify
14
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..] <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"
|
||||
|
Loading…
Reference in New Issue
Block a user