-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·52 lines (40 loc) · 1.48 KB
/
start.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
#!/bin/bash
template=${1:-"NONE"}
projName=${2:-"DUMB"}
path=${3:-"./pathGoHere"}
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [ ${template} = "NONE" ];
then
echo -e "Usage: <template> <project-name> <path-where-create-project-folder>\nTemplate available:"
for i in `ls -d1 $SCRIPTPATH/*/`; do basename $i; done
exit
fi
echo -e "creating project: ${projName}"
echo -e " template: ${template}"
echo -e " path: ${path}\n"
# check if path exists; if not, create a new directory and warn the user
if [ ! -d ${path} ];
then
mkdir ${path}
echo -e "***WARNING*** directory ${path} has been created right now; going on\n"
fi
# check if the template exists; if not, print error and exit
if [ ! -d ${SCRIPTPATH}/${template} ];
then
echo -e "***FATAL*** template ${template} not found, specify an existing one\n"
exit
fi
# check if project already exists in the given path; if yes, abort process
if [ -d ${path}/${projName} ];
then
echo -e "***FATAL*** project with name ${projName} already exists in ${path}; stopping here\n"
# if project is new, then create the package structure
else
mkdir ${path}/${projName}
cp -r ${SCRIPTPATH}/${template}/. ${path}/${projName}
# creating ChangeLog
sed -i 's/___project_name___/'${projName}'/g' ${path}/${projName}/CMakeLists.txt
echo -e "***INFO*** project ${projName} created: "
ls -lrtRA ${path}/${projName}
echo -e "***INFO*** enter the project folder and start working \n"
fi