#!/bin/sh
# Adapted from Urban Terror launch scripts
BASE_PATH=/usr/share/games/teeworlds/
BINARY=/usr/lib/games/teeworlds/teeworlds
QUIET=0
EXCUSE="\
Teeworlds client wrapper\n\
This script is Debian specific, it is *NOT* part of the source distribution!\n\
Usage: teeworlds [OPTION]...\n\
\n\
 -h, --help\t\tDisplay this help\n\
 -q, --quiet\t\tDisable console output\n\
 -f <config>\t\tSpecify the path to an alternate configuration file\n
 <command> <value>\tPass commands to the engine\n"

# Teeworlds binaries don't understand most "regular" command line parameters. Let's
# catch them here, to avoid accidently launching the binary.

while [ "$1" != "" ]; do {
	if [ "$1" = "-f" ]; then
		break;
	fi
	case "$1" in
		-h|--help)
			echo ${EXCUSE}
			exit 0
			;;
		-q|--quiet)
			QUIET=1
			;;
	esac
	shift
}; done

# Ready to rumble!

cd ${BASE_PATH}

if [ ${QUIET} -eq 1 ]; then
	exec ${BINARY} $* >/dev/null 2>&1
else
	exec ${BINARY} $*
fi

exit $?
