-
Notifications
You must be signed in to change notification settings - Fork 0
/
swako.sh
executable file
·50 lines (42 loc) · 1.21 KB
/
swako.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
#!/bin/sh -eu
#############################
# Functions
function showHelp() {
echo "usage: $ swako generate [gyb] [output]"
}
#############################
WORKSPACE=`pwd`
cd `dirname $0`
INSTALLEDSPACE=`pwd`
if [ ! `which python2.7` ]; then
echo "Python 2.7 is not installed. Please install and try again."
exit 1
fi
# Install gyb if not installed
if [ ! -x $INSTALLEDSPACE/gyb/gyb ]; then
echo "Attempt to download gyb from GitHub."
rm -rf $INSTALLEDSPACE/gyb
mkdir $INSTALLEDSPACE/gyb
curl "https://raw.githubusercontent.com/apple/swift/master/utils/gyb.py" -o $INSTALLEDSPACE/gyb/gyb.py
curl "https://raw.githubusercontent.com/apple/swift/master/utils/gyb" -o $INSTALLEDSPACE/gyb/gyb
chmod +x gyb/gyb
fi
if [ $# = 0 ]; then
subcommand="help"
else
subcommand=$1
fi
case $subcommand in
"help" )
showHelp
;;
"generate" )
gybName=$2
outputName=$3
./gyb/gyb $WORKSPACE/$gybName -o $WORKSPACE/$outputName --line-directive=
;;
"template" )
cp {$INSTALLEDSPACE,$WORKSPACE}/Endpoints_sample.swift.gyb
cp {$INSTALLEDSPACE,$WORKSPACE}/Models_sample.swift.gyb
cp {$INSTALLEDSPACE,$WORKSPACE}/sample.yml
esac