aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2023-10-25 15:35:37 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2023-10-25 15:35:37 -0400
commitea95e4099c76efe97f5d3159c659b968488ec762 (patch)
tree337dc713ca5a6b13353cd2bea3fb5d3dfacf2555
parent8f3ed01bbdf0c08033981d7284125d9f696deb16 (diff)
improved testing tools
-rwxr-xr-xnew_game15
-rwxr-xr-xsend_game48
2 files changed, 58 insertions, 5 deletions
diff --git a/new_game b/new_game
new file mode 100755
index 0000000..cf0fd5b
--- /dev/null
+++ b/new_game
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+base_url="https://jpappel.xyz/toggle"
+[ "$1" == "localhost" ] &&
+ base_url="localhost:9090/toggle"
+
+size="$2"
+[ -z "$size" ] &&
+ size="7"
+
+endpoint="game/new?size=$size"
+
+url="${base_url}/${endpoint}"
+
+curl -s "$url" | jq .
diff --git a/send_game b/send_game
index 148d699..b854b5c 100755
--- a/send_game
+++ b/send_game
@@ -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 @- |