aboutsummaryrefslogtreecommitdiff
path: root/scripts/generate-libdir-metafile.sh
blob: 8b25cbef11e34048aeedd3a9c13bb2b64b1fdf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

# this script is used to generate a mylibrary/mylibrary.pd meta file.  This
# file is read for relevant meta data when a libdir is opened. (That's the
# plan at least) <hans@at.or.at>

# keeps track of where the last bit of text was printed so that new text is
# not printed on top of existing text
Y=10

# Usage: print_pd_text($to_file, $meta_type, $text_to_print)
function print_pd_text () 
{
	 file_name="$1"; shift
	 meta_type="$1"; shift
	 echo "#X text 10 $Y ${meta_type}: $@;" >> "$file_name"
	 ((Y=Y+20))
}

if [ $# -lt 2 ]; then
	 echo "Usage: $0 BASE_DIR LIBNAME [ meta types ] "
	 echo " "
	 echo "  meta types: "
	 echo "     --author"
	 echo "     --copyright"
	 echo "     --description"
	 echo "     --keywords"
	 echo "     --license"
	 echo "     --version"
	 echo " "
else

BASE_DIR="$1"; shift
LIBNAME="$1"; shift
libdir_file_name="${BASE_DIR}/${LIBNAME}/${LIBNAME}.pd"
# create pd file
touch "${libdir_file_name}"

# create .pd header with subpatch called "PDDP_META"
echo "#N canvas 10 10 200 200 10;" >> "${libdir_file_name}"
echo "#N canvas 20 20 420 300 PDDP_META 0;" >> "${libdir_file_name}"
#N canvas 249 280 600 398 loc&precess 0;

# add required meta fields
print_pd_text "${libdir_file_name}" PDDP_META "this is a prototype of a libdir meta file"
print_pd_text "${libdir_file_name}" NAME ${LIBNAME} 


# get meta data types:
while [ $# -ge 1 ]; do
    case $1 in
		  --author)
				print_pd_text "${libdir_file_name}" AUTHOR "$2"
				;;
		  --copyright)
				print_pd_text "${libdir_file_name}" COPYRIGHT "$2"
				;;
		  --description)
				print_pd_text "${libdir_file_name}" DESCRIPTION "$2"
				;;
		  --keywords)
				print_pd_text "${libdir_file_name}" KEYWORDS "$2"
				;;
		  --license)
				print_pd_text "${libdir_file_name}" LICENSE "$2"
				;;
		  --version)
				print_pd_text "${libdir_file_name}" VERSION "$2"
				;;
		  *)
				echo "ERROR: unknown flag: $1 with data: $2"
				;;
    esac
    shift
	 shift
done

echo "#X restore 10 10 pd PDDP_META;" >> "${libdir_file_name}"


fi