-
Notifications
You must be signed in to change notification settings - Fork 17
/
generate_icommands_md.sh
executable file
·99 lines (92 loc) · 3.06 KB
/
generate_icommands_md.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
#!/bin/bash -e
SUFFIX=md
DETECTEDDIR=$( cd $(dirname $0) ; pwd -P )
TARGETDIR=${DETECTEDDIR}/docs/icommands
mkdir -p ${TARGETDIR}
TARGETFILE=$TARGETDIR/user.${SUFFIX}
echo > ${TARGETFILE}
echo "#" >> ${TARGETFILE}
echo "" >> ${TARGETFILE}
ihelp -a | grep "iRODS Version " | awk '{print $4}' | while read x ; do
if [ "$x" = "iadmin" ] ; then
# iadmin has subcommands
TARGETFILE=$TARGETDIR/administrator.${SUFFIX}
echo > ${TARGETFILE}
echo "#" >> ${TARGETFILE}
echo "" >> ${TARGETFILE}
echo "## $x" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
ihelp $x | sed \$d >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
ihelp $x | grep "^ " | grep -v "^ " | awk '{print $1}' | while read y ; do
echo "### $y" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
$x h $y >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
done
elif [ "$x" = "imeta" ] ; then
# imeta has subcommands
TARGETFILE=$TARGETDIR/metadata.${SUFFIX}
echo > ${TARGETFILE}
echo "#" >> ${TARGETFILE}
echo "" >> ${TARGETFILE}
echo "## $x" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
ihelp $x | sed \$d >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
ihelp $x | grep "^ " | grep -v "^ -" | grep -v " $" | grep -v "^ " | awk '{print $1}' | while read y ; do
echo "### $y" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
$x h $y >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
done
elif [ "$x" = "igroupadmin" ] ; then
# igroupadmin has subcommands
TARGETFILE=$TARGETDIR/groupadmin.${SUFFIX}
echo > ${TARGETFILE}
echo "#" >> ${TARGETFILE}
echo "" >> ${TARGETFILE}
echo "## $x" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
ihelp $x | sed \$d >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
ihelp $x | grep "^ " | grep -v " $" | awk '{print $1}' | while read y ; do
echo "### $y" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
$x h $y >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
done
elif [ "$x" = "iticket" ] ; then
# iticket has subcommands
TARGETFILE=$TARGETDIR/tickets.${SUFFIX}
echo > ${TARGETFILE}
echo "#" >> ${TARGETFILE}
echo "" >> ${TARGETFILE}
echo "## $x" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
ihelp $x | sed \$d >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
ihelp $x | grep "^ " | grep -v "^ -" | grep -v " $" | grep -v "^ " | awk '{print $1}' | uniq | while read y ; do
echo "### $y" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
$x h $y >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
done
else
# all other icommands
TARGETFILE=$TARGETDIR/user.${SUFFIX}
echo "## $x" >> ${TARGETFILE}
echo "<pre>" >> ${TARGETFILE}
ihelp $x | sed \$d >> ${TARGETFILE}
echo "</pre>" >> ${TARGETFILE}
echo >> ${TARGETFILE}
fi
done