#!/bin/bash

function usage () {
	echo "Usage: $0 [-cb] [-f] [-s] [-q] [highscores-file]"
	exit 1
}

options=""
scoresfile=""

for arg in $*; do
	if [ "${arg:0:1}" = "-" ]; then
		if [ "$arg" != "-cb" -a \
			"$arg" != "-f" -a \
			"$arg" != "-s" -a \
			"$arg" != "-q" ]; then
			usage
		fi
		options="$options $arg"
	elif [ -n "$scoresfile" ]; then
		usage
	else
		if [ ! -d "`dirname "$arg"`" ]; then
			echo No such file: "$arg"
			exit 1
		fi
		pushd "`dirname "$arg"`" >/dev/null
		scoresfile="`/bin/pwd`/`basename "$arg"`"
		popd >/dev/null
	fi
done

cd /usr/share/games/pathological

if [ -z "$scoresfile" ]; then
	scoresfile=/var/games/pathological_scores
fi

exec ./pathological.py $options $scoresfile
