-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_project.sh
More file actions
executable file
·99 lines (86 loc) · 1.53 KB
/
Copy pathnew_project.sh
File metadata and controls
executable file
·99 lines (86 loc) · 1.53 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
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
#!/bin/bash
function new_project()
{
if [ -e ".project_name" ]; then
PROJECT="$(cat .project_name)"
echo "$PROJECT"
elif [[ "$1" == "" ]]
then
echo -n "Project not initialized, name it: "
read -r PROJECT
if [[ "$PROJECT" == "" ]]; then
echo "quitting.."
return
fi
else
PROJECT=$1
fi
INIT=""
while [[ "$INIT" == "" ]]; do
echo "about to initialize project '$PROJECT' here:"
echo -n "$(pwd) <- OK? "
read -r INIT
case "$INIT" in
[yY] | [yY][eE][sS] | [oO][kK])
echo "Initializing $PROJECT.."
;;
[nN] | [nN][oO])
echo "quitting.."
return
;;
"")
ANSWER="no"
;;
*)
ANSWER=""
;;
esac
done
if ! [ -e "src" ]; then
echo "creating src dir.."
mkdir "src"
fi
if ! [ -e "bin" ]; then
echo "creating bin dir.."
mkdir "bin"
fi
if ! [ -e "include" ]; then
echo "creating include dir.."
mkdir "include"
fi
if [ -f "src/$PROJECT.cpp" ]; then
while [[ "$ANSWER" == "" ]]; do
echo -n "overwrite src/$PROJECT.cpp? (y/n [n]) "
read -r ANSWER
case "$ANSWER" in
[yY] | [yY][eE][sS])
echo "Overwriting $PROJECT.cpp.."
;;
[nN] | [nN][oO])
return
;;
"")
ANSWER="no"
;;
*)
ANSWER=""
;;
esac
done
else
echo "Writing $PROJECT.cpp.."
fi
echo "$PROJECT" > ".project_name"
cat << EOF > "src/$PROJECT.cpp"
#include <iostream>
int main ( ){
return 0;
}
EOF
cat << EOF > ".gitignore"
bin/
obj/
.idea/
.vscode/
EOF
}