#!/bin/sh

PHP=/usr/bin/php
REALWF=/usr/share/WackoFormatter/main.php
OPTIONS=`getopt -o h --long help,usage -n WackoFormat -- "$@"`
if [ $? != 0 ] ; then exit 1 ; fi

function usage() {
	echo >&2 "Usage:"
	echo >&2 "  WackoFormat file.wacko >file.html"
	echo >&2 "  WackoFormat <file.wacko >file.html"
	exit 0
}

eval set -- "$OPTIONS"
while true; do
	case "$1" in
		-h|--help|--usage)	usage;;
		--)			shift; break;;
	esac
done

case $# in
	0)	exec $PHP $REALWF;;
	1)	exec $PHP $REALWF <$1;;
	*) 	echo >&2 "WackoFormat: you can format only one file at a time."; exit 1;;
esac
