#!/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 .