-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.sh
74 lines (71 loc) · 1.54 KB
/
all.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
<< lib.README
#name all
#nutshell Show ALL lib functions
#usage lib all [--namespace|-n [<namespace>]] [<function>]
#story lib all # less all lib documented functions
#story lib all --namespace # less all lib documented namespaces
#story lib all --namespace Array # less all functions in the Array namespace
#story lib all Text.bold # less only documentation for bold function in Text namespace
lib.README
lib.all.view(){
file="$1"
if [ -z "$file" ]
then
read file
fi
doc=
while read line
do
if [ "$line" = '<< lib.'README ]
then
continue
elif [ ! "$line" = lib.'README' ]
then
doc="$doc
$line"
else
break
fi
done << BASH
$(cat "$file")
BASH
echo "$doc"
}
lib.all(){
if [ $# -eq 0 ]
then
echo 'lib - All' > /tmp/$$.lib.all
grep -r '<< lib.''README' $libPATH | while read line
do
file="$(echo "$line" | cut -d: -f1)"
lib.all.view "$file" >> /tmp/$$.lib.all
done
less /tmp/$$.lib.all
unlink /tmp/$$.lib.all
elif [ "$1" = '--namespace' -o "$1" = '-n' ]
then
if [ -n "$2" ]
then
namespace=$2
echo 'lib - '$namespace > /tmp/$$.lib.$namespace
grep -r '<< lib.''README' $libPATH/$namespace | while read line
do
file="$(echo "$line" | cut -d: -f1)"
lib.all.view "$file" >> /tmp/$$.lib.$namespace
done
less /tmp/$$.lib.$namespace
unlink /tmp/$$.lib.$namespace
else
ls $libPATH | while read ls
do
if [ -d "$libPATH/$ls" ]
then
echo $ls
fi
done
fi
else
function=$1
lib Regex.replace \\. / $libPATH/$function.sh 1 | lib.all.view | less
fi
}