3 # Shell script that creates a new transformation plug-in (both main and
4 # abstract class) using a template.
6 # The 'description' parameter will add a new entry in the language file.
7 # Watch out for special escaping.
11 # $3: Transformation Name
12 # $4: (optional) Description
15 if [ $# -ne 3 -a $# -ne 4 ]; then
16 echo -e "Usage: ./generator_plugin.sh MIMEType MIMESubtype TransformationName [Description]\n"
20 # make sure that the MIME Type, MIME Subtype and Transformation names
21 # are in the correct format
23 # make all names lowercase
24 MT
="`echo $1 | tr [:upper:] [:lower:]`"
25 MS
="`echo $2 | tr [:upper:] [:lower:]`"
26 TN
="`echo $3 | tr [:upper:] [:lower:]`"
27 # make first letter uppercase
31 # make the first letter after each underscore uppercase
33 MT
="`echo $MT | sed -e 's/_./\U&\E/g'`"
35 MS
="`echo $MS | sed -e 's/_./\U&\E/g'`"
37 TN
="`echo $TN | sed -e 's/_./\U&\E/g'`"
39 # define the name of the main class file and of its template
40 ClassFile
=$MT\_
$MS\_
$TN.class.php
42 # define the name of the abstract class file and its template
43 AbstractClassFile
=abstract
/"$TN"TransformationsPlugin.class.php
44 AbstractTemplate
=TEMPLATE_ABSTRACT
45 # replace template names with argument names
46 sed "s/\[MIMEType]/$MT/; s/\[MIMESubtype\]/$MS/; s/\[TransformationName\]/$TN/;" < $Template > $ClassFile
47 echo "Created $ClassFile"
49 GenerateAbstractClass
=1
51 if [ "$4" == "--generate_only_main_class" ]; then
52 if [ -e $AbstractClassFile ]; then
53 GenerateAbstractClass
=0
58 if [ $GenerateAbstractClass -eq 1 ]; then
59 # replace template names with argument names
60 sed "s/\[TransformationName\]/$TN/; s/Description of the transformation./$4/;" < $AbstractTemplate > $AbstractClassFile
61 echo "Created $AbstractClassFile"