blob: 9b35105e4e1a8e2145ed1da3409fd8bbb7e0b716 (
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
|
#!/bin/zsh
desired_build_file=${1:-all}
desired_format=${2:-pdf}
built_in_all="all"
build_base_command() {
local command_builder=""
local file_name=$1
local file_type=$2
local file_path="$PWD/src/$file_name.chordpro"
local revision=""
local xc="roman"
local x_vars=$(sed -n "s/^{\(x_.\+:.\+\)}.*/\1/p" $file_path | sed "s/:/=/")
command_builder+=" chordpro"
command_builder+=" --transcode=$xc"
command_builder+=" --config=$PWD/config.json"
if [[ -f "$PWD/configs/$file_name.json" ]] ; then
command_builder+=" --config=$PWD/configs/$file_name.json"
fi
if [ -z "" ]; then
while IFS= read -r line; do
if [[ "$line" == "x_revision"* ]]; then
revision=$(echo $line | cut -d'=' -f2)
fi
command_builder+=" --meta $line"
done <<< "$x_vars"
fi
command_builder+=" -o $PWD/out/$file_name.v$revision.$xc.$file_type"
command_builder+=" $file_path"
echo ""
echo "Starting $file_name"
echo ""
echo $command_builder
echo ""
eval ${command_builder}
}
render_all() {
for file in $PWD/src/**/*(.); do
build_base_command $file:t:r $desired_format:l &;
done
}
echo "Interpreted as request to build '${desired_build_file:l}' as '${desired_format:l}'"
if [[ $desired_build_file:l == $built_in_all:l ]] ; then
render_all
else
build_base_command $desired_build_file:l $desired_format:l
fi
|