fixed execution order bug that was causing the first two frame numbers to output...
[puredata.git] / scripts / generate-libdir-metafile.sh
bloba745c80d408deb1667a88dc31360e21f360c81ee
1 #!/bin/sh
3 # this script is used to generate a mylibrary/mylibrary.pd meta file. This
4 # file is read for relevant meta data when a libdir is opened. (That's the
5 # plan at least) <hans@at.or.at>
7 # keeps track of where the last bit of text was printed so that new text is
8 # not printed on top of existing text
9 Y=10
11 # Usage: print_pd_text($to_file, $meta_type, $text_to_print)
12 print_pd_text ()
14 file_name="$1"; shift
15 meta_type="$1"; shift
16 echo "#X text 10 $Y ${meta_type} $@;" >> "$file_name"
17 ((Y=Y+20))
20 if [ $# -lt 2 ]; then
21 echo "Usage: $0 BASE_DIR LIBNAME [ meta types ] "
22 echo " "
23 echo " meta types: "
24 echo " --author"
25 echo " --copyright"
26 echo " --description"
27 echo " --keywords"
28 echo " --license"
29 echo " --version"
30 echo " "
31 else
33 BASE_DIR="$1"; shift
34 LIBNAME="$1"; shift
35 libdir_file_name="${BASE_DIR}/${LIBNAME}/${LIBNAME}-meta.pd"
36 # create pd file
37 touch "${libdir_file_name}"
39 # create .pd header with subpatch called "META"
40 echo "#N canvas 10 10 200 200 10;" >> "${libdir_file_name}"
41 echo "#N canvas 20 20 420 300 META 0;" >> "${libdir_file_name}"
42 #N canvas 249 280 600 398 loc&precess 0;
44 # add required meta fields
45 print_pd_text "${libdir_file_name}" META "this is a prototype of a libdir meta file"
46 print_pd_text "${libdir_file_name}" NAME ${LIBNAME}
49 # get meta data types:
50 while [ $# -ge 1 ]; do
51 case $1 in
52 --author)
53 print_pd_text "${libdir_file_name}" AUTHOR "$2"
55 --copyright)
56 print_pd_text "${libdir_file_name}" COPYRIGHT "$2"
58 --description)
59 print_pd_text "${libdir_file_name}" DESCRIPTION "$2"
61 --keywords)
62 print_pd_text "${libdir_file_name}" KEYWORDS "$2"
64 --license)
65 print_pd_text "${libdir_file_name}" LICENSE "$2"
67 --version)
68 print_pd_text "${libdir_file_name}" VERSION "$2"
71 echo "ERROR: unknown flag: $1 with data: $2"
73 esac
74 shift
75 shift
76 done
78 echo "#X restore 10 10 pd META;" >> "${libdir_file_name}"