From 76a37edd56c20bf67eeb88ad880f4204da6a2d3c Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Thu, 13 Mar 2014 09:12:41 +0200 Subject: [PATCH] little helper for showing docs --- anduril/anduril-component-doc | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 anduril/anduril-component-doc diff --git a/anduril/anduril-component-doc b/anduril/anduril-component-doc new file mode 100755 index 0000000..9cac8fa --- /dev/null +++ b/anduril/anduril-component-doc @@ -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,.*\(.*\).*,\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