-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
133 lines (115 loc) · 1.88 KB
/
setup.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
verbose=false
DIRESOS=$(cat << EOF
Select an option from the following:
1 - Setup a new one with some other name
2 - Delete existing and setup a new one
3 - Git pull in the existing directory
4 - Exit program
Default Option: 3
EOF
)
WORG="https://github.com/warpdl"
WLIB=warplib
WCOR=warpdl
es() {
echo
sleep $1
}
# print won't echo if verbose is true
print() {
if [ "$verbose" = false ]
then
echo $1
else
:
fi
}
exec() {
if [ "$verbose" = false ]
then
$1 >/dev/null 2>&1
else
$1
fi
}
clone() {
print "Cloning $1 into '$2'..."
exec "git clone $1 $2"
print "Successfully cloned!"
}
pull() {
print "Running git pull..."
exec "git pull"
}
askAndClone() {
echo -n "Please enter an alternative name: "
read name
if [[ "$name" == "" ]]
then
echo "You didn't enter anything, please try again!"
askAndClone $1
else
clone $1 $name
fi
}
direso() {
repo=$WORG/$1
echo "Directory $1 exists already!"
echo "$DIRESOS"
echo
echo -n "Please input an option: "
read uinput
case $uinput in
1)
echo "You chose option 1!"
askAndClone $repo
;;
2)
echo "You chose option 2!"
echo "Deleting previous '$1' directory..."
rm -rf $1
clone $repo $1
;;
3 | "")
echo "You chose option 3!"
cd $1
pull
cd ..
;;
4)
echo "You chose option 4!"
echo "Exiting..."
;;
*)
echo "$uinput is not a valid option! Exiting..."
;;
esac
}
setupRepo() {
echo
echo "Setting up $2..."
if [ -d "$1" ];
then
direso $1
else
clone $WORG/$1 $1
fi
echo "Done!"
}
echo "WarpDL Workspace Utility"
es 2
setupRepo $WLIB "WarpLib"
es 1
setupRepo $WCOR "Warp Core"
es 1
echo "Downloaded all the required repositories!"
es 1
echo "Creating a go workspace..."
exec "go work init"
es 1
echo "Adding all the required repositories to workspace..."
exec "go work use $WCOR $WLIB"
es 1
echo "Successfully setup workspace!"
echo "Exiting in 5s..."
es 5