72 lines
2.0 KiB
Bash
Executable File
72 lines
2.0 KiB
Bash
Executable File
#!/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.
|
|
-s Display short documentation - only the names of ports and parameters.
|
|
Give component name as argument to display documentation.
|
|
|
|
Autobundles are loaded if exist.
|
|
"; }
|
|
|
|
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=""
|
|
SHORTLIST=""
|
|
options='hb:lLs'
|
|
while getopts $options option
|
|
do
|
|
case $option in
|
|
b ) bundles+=($OPTARG);;
|
|
l ) listcomps; printcomps | sort; exit;;
|
|
L ) LONGLIST="-L";;
|
|
h ) usage; exit;;
|
|
s ) SHORTLIST="yes";;
|
|
: ) 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
|
|
|
|
if [ -z "$SHORTLIST" ]
|
|
then anduril run-component $1 $BUNDLESTRING --doc $LONGLIST
|
|
else
|
|
anduril run-component $1 $BUNDLESTRING --doc $LONGLIST | grep "^[*=]"
|
|
fi
|