diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2023-10-25 15:35:37 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2023-10-25 15:35:37 -0400 |
| commit | ea95e4099c76efe97f5d3159c659b968488ec762 (patch) | |
| tree | 337dc713ca5a6b13353cd2bea3fb5d3dfacf2555 /send_game | |
| parent | 8f3ed01bbdf0c08033981d7284125d9f696deb16 (diff) | |
improved testing tools
Diffstat (limited to 'send_game')
| -rwxr-xr-x | send_game | 48 |
1 files changed, 43 insertions, 5 deletions
@@ -1,11 +1,49 @@ #!/bin/bash -endpoint="/query" -URL="https://jpappel.xyz/toggle$endpoint" -[ "$2" == "localhost" ] && - URL="localhost:9090$endpoint" +args=`getopt h:o:i: $*` +if [ $? -ne 0 ]; then + echo 'Usage: send_game [-h HOST] [-o outfile] [-i infile]' + exit 2 +fi -jq . "$1" | curl -s "$URL" \ +set -- $args + +base_url="https://jpappel.xyz/toggle" +infile="-" +outfile="/dev/fd/0" + +while :; do + case "$1" in + -h) + base_url="$2" + [ "$base_url" == "localhost" ] && + base_url="localhost:9090/toggle" + shift; shift + ;; + -o) + outfile="$2" + [ "$outfile" == "-" ] && + outfile="/dev/fd/1" + shift; shift + ;; + -i) + infile="$2" + [ "$infile" == "-" ] && + infile="/dev/fd/0" + shift; shift + ;; + --) + shift + break + ;; + esac +done + +endpoint="game/play" + +url="${base_url}/${endpoint}" + +jq . "$infile" | curl -s "$url" \ --header "Content-Type: application/json" \ --request POST \ -d @- | |
