-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.sh
executable file
·276 lines (243 loc) · 6.88 KB
/
help.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/bin/bash
# Link to github config
REPO=https://raw.githubusercontent.com/Czesiek2000/workspace-creator/master/config
# Variables use in script
CFGF=config
VERSION=1.1
# Clear terminal window
clear
# Add space to the screen
echo -e "\n"
# Change prompt text
echo -n "Something went wrong? Check out more info"
echo -e "\n0. Exit program\n1. Missing files or something wrong with files let me check\n2. Check parameters to give ex.0,1\n3. Clean your workspace\n4. Create folders and subfolders or files\n5. Help option"
echo -n "Your choice: "
read CHOICE
function download {
echo "$1 doesn't exists downloading it"
curl -O "$REPO/$1" 2> /dev/null
echo "$1 downloaded successfully"
echo "wkcr: move successfully to $CFGF file $1" >> "wkcr.log"
mv "$1" "$CFGF"
echo "wkcr/help: Move file $1 to $CFGF successfully" >> "wkcr.log"
}
# Program menu
if [ $CHOICE -eq 0 ]
then
echo "Exit help program"
echo "wkcr/help: Exit help program" >> "wkcr.log"
exit 0
elif [ $CHOICE -eq 1 ] ;
then
if [ -d $CFGF ] ;
then
echo "wkcr/help:Config folder exists " >> "wkcr.log"
else
echo "wkcr/help: Config directory doesn't exists" >> "wkcr.log"
mkdir $CFGF
echo "wkcr/help: Directory $CFGF made successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.html ] ;
then
# download example.html
echo "example.html included in script source"
fi
if [ ! -f $CFGF/example.css ] ;
then
# download example.css
echo "wkcr/help: Download example.css successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.js ] ;
then
# download example.js
echo "wkcr/help: Download example.js successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.cpp ] ;
then
#download example.cpp
echo "wkcr/help: Download example.cpp successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.py ] ;
then
download example.py
echo "wkcr/help: Download example.py successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.go ] ;
then
download example.go
echo "wkcr/help: Download example.go successfully" >> "wkcr.log"
fi
if [ ! -f $CFGF/example.ru ] ;
then
download example.ru
echo "wkcr/help: Download example.ru successfully" >> "wkcr.log"
fi
elif [ $CHOICE -eq 2 ]
then
echo "Choice 2"
echo "Available commands"
echo "wkcr/help: Help menu option 2" >> "wkcr.log"
elif [ $CHOICE -eq 3 ]
then
for i in `ls .`
do
if [ -d $i ]
then
echo "wkcr/help: $i is directory " >> "wkcr.log"
if [ "$i" != "config" ]
then
echo -e "$i/ \t"
fi
fi
done
for j in `ls .`
do
if [ -f $j ]
then
echo "wkcr/help: $j is file " >> "wkcr.log"
if [ "$j" != "wkcr.sh" ] && [ "$j" != "args.sh" ] && [ "$j" != "help.sh" ]
then
echo "-- $j"
fi
fi
done
echo -n "Give folders that you want to delete: "
read a
if [ ! -z $a ]
then
echo -n "Are you sure you want to delete given folders?(y/n): "
read b
if [ $b == "y" ]
then
echo "wkcr/help: Help choice 3 choice y" >> "wkcr.log"
for i in $a
do
if [ -f $i ]
then
echo "$i is a file"
fi
if [ -d $i ]
then
rm -r "$i"
echo "$i deleted"
fi
echo "wkcr/help: Folder $i deleted from $(pwd)" >> "wkcr.log"
done
fi
else
echo -n "Give files name to delete: "
read files
if [ -z $files ]
then
echo -n "Are you sure you want to delete them? (y/n): "
read answer
if [ "$answer" == "y" ]
then
for i in $files
do
if [ -f $i ]
then
rm $i
echo "File $i deleted"
echo "wkcr/help: $i deleted from $(pwd)" >> "wkcr.log"
else
echo "$i doesn't exists"
fi
done
fi
else
echo "wkcr/help: User enter nothing" >> "wckr.log"
fi
fi
elif [ $CHOICE -eq 4 ]
then
echo -n "You want to create files or folders? (file/folder): "
read ans
if [ $ans == "folder" ]
then
echo -n "Want to create subfolder? (y/n): "
read yn
if [ $yn == "y" ]
then
echo -n "Give folder and subfolder name with / (ex. folder/subfolder): "
read folders
for i in $folders
do
if [ -d $i ]
then
echo "$i exists"
else
echo "wkcr: Folder $i created: " >> "wkcr.log"
mkdir -p $i
fi
done
else
echo -n "Give folder / folders name you want to create: "
read FOLDERS
for i in $FOLDERS
do
echo "wkcr/help: Folder $i created " >> "wkcr.log"
mkdir $i
echo "$i created"
done
fi
elif [ $ans == "file" ]
then
echo -n "Give folder name where you want to create files: "
read D
if [ -d $D ]
then
echo "$D exists delete it with menu option"
exit 0
else
echo "wkcr: Folder $D created" >> "wkcr.log"
mkdir $D
echo "$D created"
fi
echo -n "Give file extension: "
read EXT
if [ -z $EXT ]
then
echo "wkcr/help: File create without extension " >> "wkcr.log"
echo "File create without extension"
fi
echo -n "Give name of file or files: "
read file
for j in $file
do
if [ -f $j ]
then
echo "$j exists"
else
echo "File $j created in $D" >> "wkcr.log"
if [[ $EXT =~ "." ]]
then
touch "$D/$j$EXT"
else
touch "$D/$j.$EXT"
fi
fi
done
fi
elif [ $CHOICE -eq 5 ]
then
echo "What you want to check: "
read OPTION
if [ -z $OPTION ]
then
echo -e "Usage
$ version
0-4 from menu"
elif [ $OPTION == "version" ] || [ $OPTION == "v" ]
then
echo "Current project version is: $VERSION"
# elif [ $OPTION == "" ] || [ $OPTION == "" ]
# then
# echo ""
else
echo "Command not found"
echo "Available menu options 0-4"
exit 0
fi
fi
# fi