generated from hyperk/hk-LibToolPackTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
newTool.sh
executable file
·90 lines (71 loc) · 1.82 KB
/
newTool.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
#!/bin/bash
if command -v dialog &> /dev/null
then
if [ "$1" == "" ]
then
dialog --inputbox "Enter new Tool name:" 0 0 2>answer
if [ $? -eq 0 ]
then
dir=`cat answer`
if [ "$dir" == "" ]
then
rm -f answer
clear
echo -e "\e[38;5;196mERROR!!! no Tool name given \e[0m"
exit
fi
dialog --radiolist "Select Tool Template:" 0 0 0 \
"<Blank>" . on \
`for template in \`ls template/* | grep .cpp | sed s:template/MyTool:: | sed s:.cpp::\`
do
echo $template . off
done
` 2>answer
if [ $? -eq 0 ]
then
template=`cat answer`
else
rm -f answer
clear
exit
fi
else
rm -f answer
clear
exit
fi
rm -f answer
clear
if [ "$template" == "<Blank>" ]
then
template=""
fi
else
dir=$1
template=$2
fi
else
dir=$1
template=$2
fi
if [ "$dir" != "" ]
then
if [ -d $dir ]
then
echo -e "\e[38;5;196mERROR!!! Tool directory already exists \e[0m"
else
mkdir $dir
more template/MyTool$template.h | sed s:MyTool$template:$dir:g | sed s:MYTOOL${template}_H:${dir}_H:g > ./$dir/$dir.h
more template/MyTool$template.cpp | sed s:MyTool$template:$dir:g | sed s:MyTool$template\(\):$dir\(\):g > ./$dir/$dir.cpp
more template/README.md | sed s:MyTool:$dir:g | sed s:MyTool\(\):$dir\(\):g > ./$dir/README.md
fi
else
echo -e "\e[38;5;196mError no name given \e[0m: usage = \"./newTool.sh \e[38;5;226m <ToolNAME> \e[38;5;46m <TemplateNAME> \e[0m\" if <TemplateName> is blank then blank template is used"
echo -e "Valid tools template names are:"
echo -e "\e[38;5;46m<BLANK>"
for name in `ls template/ |grep '\.h' |grep -v "h~" |sed s:"\.h"::|sed s:"MyTool"::`
do
echo $name
done
echo -e "\e[0m"
fi