-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcache.sh
executable file
·38 lines (32 loc) · 1.07 KB
/
cache.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
#!/bin/bash
# this generates cache files for instantASSIST
rm -rf cache
mkdir cache
HELP="$(realpath .)/cache/help"
CACHE="$(realpath .)/cache/cache"
CDIR="$(realpath .)/cache"
cd assists || exit 1
# generate helpfile
for i in ./*; do
echo "processing $i"
if [ -d "$i" ]; then
echo "" >>"$HELP"
echo "processing directory $i"
cd "$i" || exit
CATNAME=$(grep -o '[a-z]' <<<"$i")
mkdir "$CDIR/$CATNAME"
echo "$CATNAME: $(cat .describe)" >>"$HELP"
for u in ./*; do
echo "processing subitem $u"
SUBNAME=$(grep -o '[a-z]\.' <<<"$u" | grep -o '[a-z]')
echo " $SUBNAME$(grep '# assist: ' "$u" | grep -o ':.*')" >>"$HELP"
echo "$SUBNAME$(grep '# assist: ' "$u" | sed 's/^# assist: //g')" >>"$CDIR/$CATNAME/cache"
done
echo "" >>"$HELP"
cd .. || exit
else
SUBNAME=$(grep -o '[a-z]\.' <<<"$i" | grep -o '[a-z]')
echo "$SUBNAME$(grep '# assist: ' "$i" | grep -o ':.*')" >>"$HELP"
fi
done
grep '^[a-z]' "$HELP" | sed 's/: //g' >>"$CACHE"