Files
pi-hosted/build/generators/generateToolsREADME.sh
Rafael Blumberg 7f7773fbe9 Add Document LIst and improve build folder (#261)
* Rename generateList to generateAppList
* Add DocumenList with Generator
* Rename Template files
* Use template file for AppList.md
* Ignore case when sorting AppList
* Organize build folder
* Add dependencies check to pre-commit script
* Add wget install collumn to tools/README.md and sort by title
* Remove Document table from README and add a link to DocumentList.md
* Remove tools table from README and add a link to the list
* Hightlight AppList on Readme
2022-01-01 13:21:13 -05:00

57 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# start script from it's folder
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null || exit
# Standard file locations
homedir='../../'
. ../env.sh
## Generate Tools Table
unset table
nTools=$( jq '.tools | length' "$appinfo")
for tool in $(seq 0 $(( nTools - 1 ))); do
info=$( jq ".tools | sort_by(.File) | .[$tool]" "$appinfo" )
# Get Tool Path
FILE=$( echo "$info" | jq '.File' | tr -d '"' )
FILE="[$FILE]($Scripts$FILE)"
# Get Tool Description
DESC=$( echo "$info" | jq '.Description' | tr -d '"' )
# Get Tool Type
TYPE=$( echo "$info" | jq '.Type' | tr -d '"' )
[ "$TYPE" == "null" ] && TYPE="Install"
# Get Tool runner
EXEC=$( echo "$info" | jq '.Exec' | tr -d '"' )
[ "$EXEC" == "null" ] && EXEC="bash"
# Get Tool wget link
WGET=$( echo "$info" | jq '.wget' | tr -d '"' )
if [ "$WGET" != "null" ]; then
WGET="wget -qO- $WGET \| $EXEC"
else
unset WGET
fi
# Get Tool Installation Doc
DocID=$( echo "$info" | jq '.DocID')
if [ "$DocID" != "null" ]; then
DocFile=$(jq ".docs[] | select(.ID==$DocID) | .File" "$appinfo" | tr -d '"')
DocLink="[Documentation]($Docs$DocFile)"
else
unset DocLink
fi
line="|$FILE|$DocLink|$TYPE|$DESC|$WGET|"
if [ "$tool" == "0" ] ; then
table=$line
else
table=$( echo -e "$table\n$line")
fi
done
cp -f "$TOOLSREADME_TEMPLATE" "$TOOLSREADME"
echo -e "$table" >> "$TOOLSREADME"