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
|
set -aeou pipefail
|
||||||
|
|
||||||
GOTIFY_CLI_CONFIG_FILE="${GOTIFY_CLI_CONFIG_FILE-"$HOME/.gotify.sh"}"
|
GOTIFY_CLI_CONFIG_FILE="${GOTIFY_CLI_CONFIG_FILE-"$HOME/.gotify.sh"}"
|
||||||
|
GOTIFY_STDIN=false
|
||||||
|
|
||||||
|
|
||||||
function printHelp(){
|
function printHelp(){
|
||||||
@ -13,6 +14,7 @@ Usage ${0##*/} [options..] <Mesage>
|
|||||||
-p,--priority Set priority of the message
|
-p,--priority Set priority of the message
|
||||||
-T,--token Specify gotify app token
|
-T,--token Specify gotify app token
|
||||||
-b,--bash-completion Print out bash completion and exit
|
-b,--bash-completion Print out bash completion and exit
|
||||||
|
-s, --stdin Read STDIN instead of taking <message>
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +84,9 @@ while :; do
|
|||||||
GOTIFY_URL="$2"
|
GOTIFY_URL="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-s|--stdin)
|
||||||
|
GOTIFY_STDIN=true
|
||||||
|
;;
|
||||||
-b|--bash-completion)
|
-b|--bash-completion)
|
||||||
print_bash_completion
|
print_bash_completion
|
||||||
exit 0
|
exit 0
|
||||||
@ -100,11 +105,14 @@ while :; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if $GOTIFY_STDIN; then
|
||||||
if [[ -z "${1-}" ]]; then
|
read -r MESSAGE
|
||||||
|
elif [[ -z "${1-}" ]]; then
|
||||||
printf "ERROR: No message to send\n" >&2
|
printf "ERROR: No message to send\n" >&2
|
||||||
printHelp
|
printHelp
|
||||||
exit 2
|
exit 2
|
||||||
|
else
|
||||||
|
MESSAGE="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sendMessage "${1-}"
|
sendMessage "$MESSAGE"
|
||||||
|
Loading…
Reference in New Issue
Block a user