forked from jkstill/oracle-script-lib
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gen-readme.sh
executable file
·48 lines (37 loc) · 978 Bytes
/
gen-readme.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
#!/bin/bash
baseURL='https://github.com/jkstill/oracle-script-lib/blob/master/sql'
readmeFile='README.md'
heading () {
local -r idxHdr="$*"
echo '</pre>'
echo "<h3>$idxHdr</h3>"
echo '<pre>'
:
}
content () {
local sqlInfo="$*"
sqlInfo=${sqlInfo:1}
local sqlScript=$(echo $sqlInfo | cut -f1 -d:)
local sqlDesc=$(echo $sqlInfo | cut -f2 -d:)
echo "<a href='$baseURL/$sqlScript'>$sqlScript</a> -$sqlDesc"
}
echo > $readmeFile
echo '<html>' >> $readmeFile
echo '<body>' >> $readmeFile
# assumes the first line is a header
echo "<pre>" >> $readmeFile
while read line
do
#echo Line: "=== $line ==="
# lines ending in : are headings
# lines beginning with @ are script names and descriptions
leadingChr=${line:0:1}
#echo LeadingChar: $leadingChr
case $leadingChr in
@) content "$line";;
*) heading "$line";;
esac
done < <(grep -vE '^#|^\s*$' INDEX) >> $readmeFile
echo '</pre>' >> $readmeFile
echo '</body>' >> $readmeFile
echo '</html>' >> $readmeFile