blob: b854b5ca48d46b0300c557b26efee4f71300d9cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/bash
args=`getopt h:o:i: $*`
if [ $? -ne 0 ]; then
echo 'Usage: send_game [-h HOST] [-o outfile] [-i infile]'
exit 2
fi
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 @- |
jq .
|