#!/bin/tcsh -f

if ($?STARLAB_INSTALL_PATH == 0) then
    echo STARLAB_INSTALL_PATH not set
    exit
endif

if (! -d $STARLAB_INSTALL_PATH/bin) then
    echo No bin directory in STARLAB_INSTALL_PATH
    exit
endif

cd $STARLAB_INSTALL_PATH/bin
set tmp = (`/bin/ls`)

if ($#tmp <= 0) then
    echo No files in STARLAB_INSTALL_PATH/bin
    exit
endif

# Generate some simple HTML and links to the program descriptions.

if (! -d HTML) then
    mkdir HTML
endif
set index = HTML/index.html
if (-e $index) then
    rm -rf $index
endif
touch $index

echo "<head><title>Current Starlab Tools</title></head>"	>>  $index
echo "<html>"							>>  $index
echo "<h1>List of Current Starlab Tools</h1>"			>>  $index
echo "(automatically generated by list_tools from --help output)"  >>  $index
echo "<br>"							>>  $index

foreach tool ($tmp)
    echo $tool
    $tool --help					>&! HTML/$tool.txt
    set tmp1 = (`grep Starlab HTML/$tool.txt`)
    if ($#tmp1 <= 0) then
	rm -rf HTML/$tool.txt
    else
	echo "<br><a href=$tool.txt>$tool</a>"			>>  $index
    endif
end
echo "</html>"							>>  $index
