deprecating component print
This commit is contained in:
@@ -1,130 +0,0 @@
|
|||||||
#!/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.
|
|
||||||
"; }
|
|
||||||
|
|
||||||
|
|
||||||
add_autobundles () {
|
|
||||||
for b in $( find -L "$ANDURIL_HOME" -maxdepth 2 -name bundle.xml );
|
|
||||||
do if grep -i autoload.*true "$b" > /dev/null
|
|
||||||
then bundles+=( $( dirname "$b" ) )
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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]} )\""
|
|
||||||
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 -L ${bundles[$i]} -maxdepth 3 -mindepth 3 -name component.xml -printf '%P\n' | sed -e 's,/component.xml,,' -e s,.*/,"\($bname\):", | sort ) )
|
|
||||||
done
|
|
||||||
}
|
|
||||||
printcomps () {
|
|
||||||
for ((i=0; i<${#compList[@]}; i++ )) do
|
|
||||||
echo ${compList[$i]}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
listdoc () {
|
|
||||||
|
|
||||||
local e_code
|
|
||||||
if [ -z "$SHORTLIST" ]
|
|
||||||
then anduril run-component $1 $BUNDLESTRING --doc --log /tmp/anduril_doc_log $LONGLIST
|
|
||||||
else
|
|
||||||
anduril run-component $1 $BUNDLESTRING --doc --log /tmp/anduril_doc_log $LONGLIST | grep "^[*=]"
|
|
||||||
fi
|
|
||||||
e_code=$?
|
|
||||||
rm -rf /tmp/anduril_doc_log
|
|
||||||
return $e_code
|
|
||||||
}
|
|
||||||
|
|
||||||
bundles=( )
|
|
||||||
LONGLIST=""
|
|
||||||
SHORTLIST=""
|
|
||||||
options='hb:lLs'
|
|
||||||
while getopts $options option
|
|
||||||
do
|
|
||||||
case $option in
|
|
||||||
b ) bundles+=($OPTARG);;
|
|
||||||
l ) add_autobundles; listcomps; printcomps; exit;;
|
|
||||||
L ) LONGLIST="-L";;
|
|
||||||
h ) usage; exit;;
|
|
||||||
s ) SHORTLIST="yes";;
|
|
||||||
: ) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
|
||||||
|
|
||||||
if [ ! -e "$ANDURIL_HOME/anduril.jar" ]
|
|
||||||
then echo ANDURIL_HOME/anduril.jar not found!
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
add_autobundles
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
listdoc "$1"
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then listcomps
|
|
||||||
echo "Maybe you were looking for:"
|
|
||||||
substrings=( $( printcomps | sed 's,.*):,,' | grep -i "$1" ) )
|
|
||||||
if [ ${#substrings[@]} -eq 1 ] # only 1 match found!
|
|
||||||
then echo ${substrings[0]}
|
|
||||||
listdoc ${substrings[0]}
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if [ ${#substrings[@]} -gt 1 ] # multiple matches
|
|
||||||
then printcomps | grep -i ":.*$1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# no grep matches, bring out the heavy artillery:
|
|
||||||
printcomps | sed 's,.*):,,' | python <( echo '
|
|
||||||
import difflib as dl
|
|
||||||
import sys
|
|
||||||
match=[]
|
|
||||||
ratio=[]
|
|
||||||
for line in sys.stdin:
|
|
||||||
s=dl.SequenceMatcher(None, line, "'$1'")
|
|
||||||
s_ratio=s.ratio()
|
|
||||||
if s_ratio > 0:
|
|
||||||
ratio.append(s_ratio)
|
|
||||||
match.append(line.strip())
|
|
||||||
sorted_ratios=[i[0] for i in sorted(enumerate(ratio), key=lambda x:x[1])]
|
|
||||||
best_matches=[match[i] for i in sorted_ratios[-5:]]
|
|
||||||
best_matches.reverse()
|
|
||||||
print( ", ".join(best_matches))
|
|
||||||
' )
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../anduril/anduril-component-print
|
|
||||||
Reference in New Issue
Block a user