#!@SKG_BASH@
#$1=id
#$2=description
#$3=authors

#example: addNewPlugin.sh print "A skrooge plugin to print pages" "Stephane MANKOWSKI"
P="@CMAKE_SOURCE_DIR@"
idupper=`echo $1 | tr [a-z] [A-Z]`
idlower=`echo $1 | tr [A-Z] [a-z]`
description="$2"
author="$3"

mkdir ${P}/skrooge_${idlower}
for i in ${P}/templates/skrooge_xxx/*
do
	file=`basename $i | sed -e "s,XXX,${idupper},g" | sed -e "s,xxx,${idlower},g"`
	echo "Creation of ./skrooge_${idlower}/${file}"
	cat $i | sed -e "s,XXX,${idupper},g" | sed -e "s,xxx,${idlower},g" | sed -e "s,##DESCRIPTION##,${description},g" | sed -e "s,##AUTHOR##,${author},g" > ${P}/skrooge_${idlower}/${file}
done

echo "Don't forget to add this line in CMakeLists.txt:"
echo "  ADD_SUBDIRECTORY(skrooge_${idlower})"
