little helper for showing docs
This commit is contained in:
61
anduril/anduril-component-doc
Executable file
61
anduril/anduril-component-doc
Executable 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
|
||||
Reference in New Issue
Block a user