-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot-maker.sh
executable file
·58 lines (41 loc) · 1.44 KB
/
robot-maker.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
55
56
57
58
#!/bin/bash
BASE_ROBOT_REPO=https://github.com/SouthEugeneRoboticsTeam/Robot-Base
usage() {
echo "Usage: $(basename $0) <path>"
}
# Check for `-h` option
if [ "$1" == "-h" ]; then
usage
exit 0
fi
ROBOT_PATH=$1
GAME_NAME_FULL=${ROBOT_PATH##*/}
GAME_NAME=${GAME_NAME_FULL%-*}
YEAR=${GAME_NAME_FULL##*-}
GAME_NAME_SM=$(echo $GAME_NAME | tr "[:upper:]" "[:lower:]")
# Verify that params are set
if [ -z "$ROBOT_PATH" ] || [ -z "$GAME_NAME" ] || [ -z "$YEAR" ]; then
usage
exit 1
fi
# Clone base repository
git clone -q --depth=1 $BASE_ROBOT_REPO $ROBOT_PATH
cd $ROBOT_PATH
# Remove git files
rm -rf .git
# Replace references of base `gamename` with the actual $GAME_NAME
sed -i.bak "s/org\.sert2521\.gamename/org\.sert2521\.$GAME_NAME_SM/g" build.gradle
find src -type f -print0 | xargs -0 sed -i.bak "s/org\.sert2521\.gamename/org\.sert2521\.$GAME_NAME_SM/g"
# Remove backup files
find . -type f -name "*.bak" -delete
# Rename `gamename` directories to the actual $GAME_NAME
mv src/main/java/org/sert2521/gamename src/main/java/org/sert2521/$GAME_NAME_SM
# Remove README and create new one from README_TEMPLATE
rm README.md
cat README_TEMPLATE.md | sed "s/{{name}}/$GAME_NAME/g" | \
sed "s/{{name_full}}/$GAME_NAME_FULL/g" | \
sed "s/{{year}}/$YEAR/g" > README.md
rm README_TEMPLATE.md
git init -q
echo "Robot creation complete!"
echo "Use \`git remote add origin <repo_url>\`, then push to GitHub."