little helper for showing docs

This commit is contained in:
ville rantanen
2014-03-13 09:12:41 +02:00
parent a87a8dedf0
commit 76a37edd56

61
anduril/anduril-component-doc Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
usage () { echo "
Anduril component documentation console utility.
-b [bundledir] Include bundles. Multiple -b's accepted.
-l List all components in the given bundles.
-L Display example usage of the component.
Give component name as argument to display documentation."; }
bundlefunc () {
for ((i=0; i<${#bundles[@]}; i++ )) do
[[ -a ${bundles[$i]}/bundle.xml ]] || echo Bundle ${bundles[$i]} not found || exit 1
BUNDLESTRING=${BUNDLESTRING}" -b \"$( readlink -f ${bundles[$i]} )\""
RUNNERSTRING=${RUNNERSTRING}"//$ -b \"$( readlink -f ${bundles[$i]} )\" \n"
done
}
listcomps () {
compList=( )
for ((i=0; i<${#bundles[@]}; i++ )) do
bname=$( cat ${bundles[$i]}/bundle.xml | tr -d -c [:print:] | tr " " _ | sed 's,.*<name>\(.*\)</name>.*,\1,' )
[[ -a ${bundles[$i]}/bundle.xml ]] || echo Bundle ${bundles[$i]} not found || exit 1
compList+=( $( find ${bundles[$i]} -maxdepth 3 -mindepth 3 -name component.xml -printf '%P\n' | sed -e 's,/component.xml,,' -e s,.*/,"\($bname\):", ) )
done
}
printcomps () {
for ((i=0; i<${#compList[@]}; i++ )) do
echo ${compList[$i]}
done
}
bundles=( )
LONGLIST=""
options='hb:lL'
while getopts $options option
do
case $option in
b ) bundles+=($OPTARG);;
l ) listcomps; printcomps | sort; exit;;
L ) LONGLIST="-L";;
h ) usage; exit;;
: ) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
esac
done
shift $(($OPTIND - 1))
bundlefunc
if [ -z "$1" ]
then usage
echo -e "\n\nComponent name missing"
exit
fi
if [ -e "$1".and ]
then echo -e "\n\nFile $1.and already exists. Remove it first."
exit
fi
anduril run-component $1 $BUNDLESTRING --doc $LONGLIST