-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildLab.sh
executable file
·105 lines (95 loc) · 2.44 KB
/
buildLab.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
#!/bin/bash
selectBranch(){
branch="main" #Default Branch
if [[ $# != 0 ]]; then
if [[ $1 != "$branch" && "$1" == "up" ]]; then
branch="develop"
else
exit_failure "'$1' is not a valid choice!"
fi
fi
}
gray() {
echo -e "\e[90m${1}\e[0m"
}
selectTemplate(){
while true; do
echo -e "\e[90m=========\e[0m Select your \e[32mC++ Template\e[0m \e[90m=========\e[0m"
echo -e "If you don't know what choose, select \e[32mBasic\e[0m"
echo -e "\e[32m1\e[0m) \e[32mBasic\e[0m - 32 lines"
echo -e "\e[33m2\e[0m) \e[33mStandard\e[0m - 40 lines"
echo -e "\e[31m3\e[0m) \e[31mComplex\e[0m - 58 lines"
echo -e "\e[95m4\e[1m) \e[95mMaster\e[0m - 101 lines"
gray "============================================"
echo -n "My choice is: "
read -r choice
case "$choice" in
1)
template="basic"
break
;;
2)
template="standard"
break
;;
3)
template="complex"
break
;;
4)
template="master"
break
;;
*)
echo -e "\e[31m<Invalid Choice>\e[0m Please, select a valid option"
;;
esac
done
}
settings(){
selectBranch $1
selectTemplate
printf "\nDownloading template ...\n"
solutionTemplate=$(curl -s https://raw.githubusercontent.com/propilideno/cp-tips/$branch/templates/cpp/$template.cpp)
makefileTemplate=$(curl -s https://raw.githubusercontent.com/propilideno/cp-tips/$branch/templates/cpp/Makefile)
printf "Complete!\n\n"
}
chr() {
local ascii_Value=$(awk -v v="$1" 'BEGIN{printf "%c", v}')
echo "$ascii_Value"
}
createFiles(){
read -p "Type filename: " fileName
read -p "Type number of questions: " numberOf_Questions
mkdir $fileName
cd $fileName
echo -e "$makefileTemplate" > Makefile #Create MakeFile
mkdir input
for((i=97;i<97+$numberOf_Questions;i++));do
solutionName=$(chr $i)
echo -e "$solutionTemplate" > $solutionName.cpp #Create Solution's Template
touch input/$solutionName.txt #Create empty folers for input
done
}
exit_failure(){
echo "Something got wrong! Check our current documentation in: https://propi.dev/cp"
if [[ $# != 0 ]]; then
echo "<ERROR> $1"
fi
exit 1
}
greetings(){
printf "\n==> All files was created with SUCCESS !!!\n"
echo "==> Contribute with us giving this repo a Star ⭐"
echo "Maintainers:"
printf "\t - Lucas R. de Almeida | hello@propi.dev\n"
echo "Honorable Mentions:"
printf "\t - Giovanni V. Comarela | gc@inf.ufes.br\n"
exit 1
}
main(){
settings $1
createFiles
greetings
}
main $1