-
Notifications
You must be signed in to change notification settings - Fork 0
/
bake
executable file
·38 lines (30 loc) · 1.07 KB
/
bake
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
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
usage="bake -b <bookname> -i <inputfile> -o <outputfile> -r <resourcedir> -p <platform>"
platform='default'
resource_dir=0
# Get command line arguments
while getopts b:i:o:r:p:h flag
do
case "${flag}" in
b) book=${OPTARG} ;;
i) input_file=${OPTARG} ;;
o) output_file=${OPTARG} ;;
r) resource_dir=${OPTARG} ;;
p) platform=${OPTARG} ;; # web or default (pdf)
h) echo $usage; exit 0 ;;
*) echo "Unknown flag '${flag}'"; exit 1 ;;
esac
done
# Call the baking script based on the book.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Bake with or without resources
if [[ $resource_dir == 0 ]]; then
if [[ $platform == 'web' ]]; then
echo "ERROR: resources required when baking for web"
exit 1
fi
$DIR/lib/recipes/bake --input $input_file --output $output_file --recipe $book --platform $platform
else
$DIR/lib/recipes/bake --input $input_file --output $output_file --recipe $book --resources $resource_dir --platform $platform
fi