#!/bin/bash 
#
# thot -- manager script for thot development.
#
do=""
if [ "$1" = "-n" ]
then
	shift
	do=echo
fi

wescamp=~/svn/wescamp-i18n/The_Hammer_of_Thursagan
thotpath=data/campaigns/The_Hammer_of_Thursagan
client=~/svn/wesnoth/utils/campaigns_client.py

if [ -L ~/svn/wesnoth/$thotpath ]
then
	dthot=linked
elif [ -d ~/svn/wesnoth/$thotpath ]
then
	uthot=copied
else
	dthot="not present"
fi

if [ -L ~/.wesnoth/$thotpath ]
then
	uthot=linked
elif [ -d ~/.wesnoth/$thotpath ]
then
	uthot=copied
else
	uthot="not present"
fi

case $1 in
upload)
   echo "Uploading THoT to campaign server";
   $do $client -p 1.3.x -c ~/svn/wescamp-i18n -u The_Hammer_of_Thursagan;
   ;;
remove)
   case $uthot in
   linked)
       echo "Unlinking THoT from user directory";
       $do rm ~/.wesnoth/$thotpath;;
   copied)
       echo "Removing THoT from user directory";
       $do rm -fr ~/.wesnoth/$thotpath;;
   *)
       echo "ThoT not installed in user directory."
   esac
   ;;
relink)
   thot remove
   echo "Relinking THoT to data directory";
   $do ln -s $wescamp ~/svn/wesnoth/$thotpath;
   ;;
delink)
   echo "Delinking THoT from data directory";
   $do rm ~/svn/wesnoth/$thotpath;
   ;;
nuke)
   echo -n "Password: "
   read password
   $do $client -r The_Hammer_of_Thursagan -P "$password";
   ;;
story)
   asciidoc -a toc STORY;
   mv STORY.html ~/WWW/wesnoth/thot.html
   cd ~/WWW; upload wesnoth/thot.html
   ;;
*)
    echo "ThoT $uthot in user directory."
    echo "ThoT $dthot in data directory."
    ;;
esac
