-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcompile.sh
executable file
·54 lines (49 loc) · 1.19 KB
/
compile.sh
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
#!/bin/bash
timing=0
scriptfolder="$HOME/Library/Application Scripts/com.omnigroup.OmniFocus3"
usage="$(basename "$0") [-h] DIRECTORY
where:
-h show this help and exit
DIRECTORY directory of the script"
while getopts ':ht' option; do
case "$option" in
t) timing=1
;;
h) echo "$usage"
exit
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
input=${1////}
if [ "$input" == "Library" ]; then
srcone="Library/omnifocuslib.applescript"
trgtone="$HOME/Library/Script Libraries/omnifocuslib.scpt"
if [ -f "$trgtone" ]; then
rm "$trgtone"
fi
if [ $timing == 1 ]; then
srctwo="Library/timinglib.applescript"
trgttwo="$HOME/Library/Script Libraries/timinglib.scpt"
if [ -f "$trgttwo" ]; then
rm "$trgttwo"
fi
cmd="osacompile -o \"$trgttwo\" \"$srctwo\""
else
cmd="printf \"\""
fi
osacompile -o "$trgtone" "$srcone" && eval "$cmd" && echo "DONE"
else
lowercase=$(echo "$input" | tr '[:upper:]' '[:lower:]')
bn=${lowercase//[[:blank:]]/}
src="$input"/"$bn".applescript
trgt="$scriptfolder"/"$bn".scpt
if [ -f "$trgt" ]; then
rm "$trgt"
fi
osacompile -o "$trgt" "$src" && echo "DONE"
fi