-
Notifications
You must be signed in to change notification settings - Fork 1
/
mko.sh
executable file
·109 lines (106 loc) · 2.47 KB
/
mko.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
#! /bin/bash
# mkc.sh
# Created by Barrett Lewis
# creats a class and header file
# creates basic functions
NAME=$1
FNAME=$(echo $1 | tr '[A-Z]' '[a-z]')
CPP="${FNAME}.cpp"
H="${FNAME}.h"
CPPL="`pwd`/${CPP}" #location that cpp will exist in
HL="`pwd`/${H}" #location that h will exist
function createCPP() #creates the CPP files
{
echo Making file:$CPP
echo "#include \"${H}\"" > $CPP
echo >> $CPP
echo "${NAME^}::${NAME^}()" >> $CPP
echo "{" >> $CPP
echo >> $CPP
echo "}" >> $CPP
echo >> $CPP
echo "${NAME^}::~${NAME^}()" >> $CPP
echo "{" >> $CPP
echo >> $CPP
echo "}" >> $CPP
}
function createH() #create h file
{
echo Making file:$H
echo "#ifndef ${NAME^^}_H" > $H
echo "#define ${NAME^^}_H" >> $H
echo >> $H
echo "#include <iostream>" >> $H
echo "using namespace std;" >> $H
echo >> $H
echo "class ${NAME^}" >> $H
echo "{" >> $H
echo " public:" >> $H
echo " ${NAME^}();" >> $H
echo " ~${NAME^}();" >> $H
echo " protected:" >> $H
echo " private:" >> $H
echo >> $H
echo "};" >> $H
echo >> $H
echo "#endif" >> $H
}
if [ ! -f $CPPL -a ! -f $HL ]
then
echo Using name $1
createCPP
createH
vim -O $H $CPP
elif [ -f $CPPL -a ! -f $HL ]
then
echo using name $1
createH
echo "<${CPP}> already exists in location <${CPPL}>"
echo "Overwrite <${CPP}>, this process can't be reversed"
while true; do #get user input about replacing cpp
read -p " Yes or No " yn
case $yn in
[Yy]* ) createCPP; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
vim -O $H $CPP
elif [ ! -f $CPPL -a -f $HL ]
then
echo using name $1
createCPP
echo "<${H}> already exists in location <${HL}>"
echo "Overwrite <${H}>, this process can't be reversed"
while true; do
read -p " Yes or No " yn
case $yn in
[Yy]* ) createH; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
vim -O $H $CPP
else
echo "<${H}> already exists in location <${HL}>"
echo "Overwrite <${H}>, this process can't be reversed"
while true; do
read -p " Yes or No " yn
case $yn in
[Yy]* ) createH; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "<${CPP}> already exists in location <${CPPL}>"
echo "Overwrite <${CPP}>, this process can't be reversed"
while true; do #get user input about replacing cpp
read -p " Yes or No " yn
case $yn in
[Yy]* ) createCPP; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
vim -O $H $CPP
fi