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
|
#!/bin/bash
exe=wb_command
outDir='.'
function command_to_page_name ()
{
echo "command""$1"".html"
}
#make a page containing just the text output, no links, substituting special characters as needed
function make_basic_command_page ()
{
local commandName="$1"
local outPage="$outDir/`command_to_page_name $commandName`"
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' > "$outPage"
echo '<HTML>' >> "$outPage"
echo "<HEAD><TITLE>wb_command $commandName help information</TITLE></HEAD>" >> "$outPage"
echo '<BODY><pre>' >> "$outPage"
#body
echo "`$exe $commandName`" | sed 's/</\</g' | sed 's/>/\>/g' >> "$outPage"
#end page
echo '</pre></BODY>' >> "$outPage"
echo '</HTML>' >> "$outPage"
}
#start main page - note that this assumes a particular order of the listed info commands, change and add as needed
initialText=`$exe`
startPage="wb_command_help.html"
#page header
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' > "$outDir/$startPage"
echo '<HTML>' >> "$outDir/$startPage"
echo '<HEAD><TITLE>wb_command help information</TITLE></HEAD>' >> "$outDir/$startPage"
echo '<BODY><pre>' >> "$outDir/$startPage"
#body
infoLine=`echo "$initialText" | grep -n Information | cut -f1 -d:`
#include -help line as plain text
echo -n "$initialText" | head -n $((infoLine + 1)) >> "$outDir/$startPage"
#-arguments-help
make_basic_command_page "-arguments-help"
echo -n '<a href="'`command_to_page_name -arguments-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -arguments-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-global-options
make_basic_command_page "-global-options"
echo -n '<a href="'`command_to_page_name -global-options`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -global-options >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-parallel-help
make_basic_command_page "-parallel-help"
echo -n '<a href="'`command_to_page_name -parallel-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -parallel-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-cifti-help
make_basic_command_page "-cifti-help"
echo -n '<a href="'`command_to_page_name -cifti-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -cifti-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-gifti-help
make_basic_command_page "-gifti-help"
echo -n '<a href="'`command_to_page_name -gifti-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -gifti-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-volume-help
make_basic_command_page "-volume-help"
echo -n '<a href="'`command_to_page_name -volume-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -volume-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-version
echo "$initialText" | grep -- -version >> "$outDir/$startPage"
#-list-commands
#special code to make page below
echo -n '<a href="'`command_to_page_name -list-commands`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -list-commands >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-list-deprecated-commands
#again, special code below
echo -n '<a href="'`command_to_page_name -list-deprecated-commands`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -- -list-deprecated-commands >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#-all-commands-help - takes 2 lines!
make_basic_command_page "-all-commands-help"
echo -n '<a href="'`command_to_page_name -all-commands-help`'">' >> "$outDir/$startPage"
echo "$initialText" | grep -A 1 -- -all-commands-help >> "$outDir/$startPage"
echo -n '</a>' >> "$outDir/$startPage"
#remainder of help info
allCommandsLine=`echo "$initialText" | grep -n -- -all-commands-help | cut -f1 -d:`
echo "$initialText" | tail -n +$((allCommandsLine+2)) >> "$outDir/$startPage"
#end main page
echo '</pre></BODY>' >> "$outDir/$startPage"
echo '</HTML>' >> "$outDir/$startPage"
#-list-commands page, and its subpages
outPage="$outDir/`command_to_page_name -list-commands`"
#header
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' > "$outPage"
echo '<HTML>' >> "$outPage"
echo '<HEAD><TITLE>wb_command -list-commands help information</TITLE></HEAD>' >> "$outPage"
echo '<BODY><pre>' >> "$outPage"
#body
readarray -t lines < <($exe -list-commands)
for ((i = 0; i < ${#lines[@]}; ++i))
do
thisCommand=`echo ${lines[$i]} | cut -f1 -d' '`
make_basic_command_page "$thisCommand"
echo '<a href="'"`command_to_page_name $thisCommand`"'">'"${lines[$i]}"'</a>' >> "$outPage"
done
#end -list-commands page
echo '</pre></BODY>' >> "$outPage"
echo '</HTML>' >> "$outPage"
#-list-deprecated-commands page, and its subpages
outPage="$outDir/`command_to_page_name -list-deprecated-commands`"
#header
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' > "$outPage"
echo '<HTML>' >> "$outPage"
echo '<HEAD><TITLE>wb_command -list-deprecated-commands help information</TITLE></HEAD>' >> "$outPage"
echo '<BODY><pre>' >> "$outPage"
#body
readarray -t lines < <($exe -list-deprecated-commands)
for ((i = 0; i < ${#lines[@]}; ++i))
do
thisCommand=`echo ${lines[$i]} | cut -f1 -d' '`
make_basic_command_page "$thisCommand"
echo '<a href="'"`command_to_page_name $thisCommand`"'">'"${lines[$i]}"'</a>' >> "$outPage"
done
#end -list-deprecated-commands page
echo '</pre></BODY>' >> "$outPage"
echo '</HTML>' >> "$outPage"
|