forked from realRoshanRaj/ECE461-P2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·55 lines (51 loc) · 1.26 KB
/
run
File metadata and controls
executable file
·55 lines (51 loc) · 1.26 KB
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
#!/bin/bash
# URL PATTERN GOTTEN FROM CHATGPT
urlPattern='^(http|https)://[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$'
dir='CLI/'
filePathPattern='^(.+)\/([^\/]+)$'
help() {
echo 'Usage: ./run [install|build|URL_FILE|FILEPATH|test]'
echo '------------ Sample Commands ----------------------'
echo 'install - Installs any dependencies in userland'
echo 'build - Completes any compilation needed'
echo 'URL_FILE - Main function - rates a repo'
echo 'FILEPATH - Main function - rates all repos in file'
echo 'test - Runs test suite'
echo '---------------------------------------------------'
}
if [ -z "$1" ]; then
echo -e "\033[31mERROR: No argument passed.\033[0m"
help
exit 1
elif [ $1 == 'install' ]; then
echo 'INSTALLING DEPENDENCIES'
cd $dir
make install
exit 0
elif [ $1 == 'build' ]; then
echo 'BUILDING'
cd $dir
make build
exit 0
elif [ $1 == 'test' ]; then
echo 'TESTING'
cd $dir
go test ./... -cover
exit 0
elif [ $1 == 'URL_FILE' ]; then
echo 'RUNNING'
cd $dir
make url
exit 0
elif [ $1 = 'help' ]; then
help
exit 0
elif [[ $1 =~ $filePathPattern ]]; then
echo "FILEPATH_PATTERN"
./CLI/executable $1
exit 0
else
echo -e "\033[31mINVALID COMMAND: '$1'\033[0m"
help
exit 1
fi