Last active
September 12, 2023 05:26
-
-
Save augiedoggie/3db799604b243436aafa91db832d3964 to your computer and use it in GitHub Desktop.
Command line tool to send messages to the developer console by PulkoMandy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
usage() { | |
echo "$0 [-s] [-e] [-l] [-d] [-c <#>] <name> <text>" | |
echo " -s Send success message" | |
echo " -e Send error message" | |
echo " -l Add separator line" | |
echo " -d Delete all messages" | |
echo " -c <#> Use color # [0-6]" | |
echo " Only one of -s, -e, -l, or -d can be used" | |
echo " A standard message will be sent unless -s or -e are used" | |
exit 1 | |
} | |
dcSig=application/x-vnd.ml-BeDCApp | |
dcMsg=bedc | |
msgType=0 | |
msgColor=0 | |
checkProcess() { | |
if [ -z "`roster -t | grep $dcSig`" ];then | |
echo "BeDC not running!" | |
exit 1 | |
fi | |
} | |
while getopts ":seldc:" option; do | |
case "$option" in | |
s) | |
msgType=1 | |
;; | |
e) | |
msgType=2 | |
;; | |
l) | |
checkProcess | |
hey -s $dcSig $dcMsg with bedc_type='int8(3)' | |
exit 0 | |
;; | |
d) | |
checkProcess | |
hey -s $dcSig $dcMsg with bedc_type='int8(4)' | |
exit 0 | |
;; | |
c) | |
msgColor=$OPTARG | |
#TODO verify color is valid? | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
if [ -z "$1" ] || [ -z "$2" ] ; then | |
echo "Not enough arguments!" | |
usage | |
fi | |
checkProcess | |
hey -s $dcSig $dcMsg with bedc_type="int8($msgType)" and bedc_color="int8($msgColor)" and bedc_name="$1" and bedc_text="$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment