diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index 937ceb3..40cf10a 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -6,8 +6,8 @@ ## Version information -VERSION_REV=7 -VERSION_MAJOR=1 +VERSION_REV=8 +VERSION_MAJOR=0 VERSION_MINOR=0 ## Start of generic script part @@ -17,7 +17,7 @@ DRY=0 VERBOSE=0 ERNO=0 STEP_ARGS= -MAX_STEP=255 +MAX_STEP=512 ALIAS= TEMPLATE_NAME=seqTemplateExample.sh MISSING_CONF=missingConf.log @@ -52,7 +52,16 @@ helpSequencer() { } helpApi() { - echo "sequencer.sh build-in functions" + echo "sequencer.sh API" + echo + echo "The sequencer.sh build-in functions are available in all sequence functions:" + echo "- step_config" + echo " If optional step_config is defined in the sequence, it will be called once before any step." + echo "- step_[1-${MAX_STEP}]_info" + echo "- step_[1-${MAX_STEP}]_alias" + echo "- step_[1-${MAX_STEP}]" + echo + echo "sequencer.sh build-in functions:" echo echo " exe [COMMANDLINE]" echo " Execute command line without pipes or redirects (>,<,|)." @@ -346,7 +355,14 @@ execute() { return 0 ;; *) - echo " [I] Stopping sequence at step $1" + local stepId="$1" + # Display alias if exists + existsFunction step_${1}_alias + if [ $? -eq 0 ] ; then + step_${i}_alias + stepId="$ALIAS" + fi + echoerr " [I] Stopping sequence at step: $stepId" exit 1; ;; esac @@ -448,6 +464,20 @@ createTemplate() { fi echo "#!/bin/bash" > $TEMPLATE_NAME echo >> $TEMPLATE_NAME + echo "toolName=mytool" >> $TEMPLATE_NAME + echo >> $TEMPLATE_NAME + echo "# Get script working directory" >> $TEMPLATE_NAME + echo "# (when called from a different directory)" >> $TEMPLATE_NAME + echo "WDIR=\"\$( cd \"\$( dirname \"\${BASH_SOURCE[0]}\" )\" >>/dev/null 2>&1 && pwd )\"" >> $TEMPLATE_NAME + echo "CONFIG_FILE=\"\$WDIR/\${toolName}.cfg\"" >> $TEMPLATE_NAME + echo "CONFIG_FILE_DEFAULT=\"\${CONFIG_FILE}.example\"" >> $TEMPLATE_NAME + echo >> $TEMPLATE_NAME + echo "step_config() {" >> $TEMPLATE_NAME + echo " echo \"Called once before executing steps.\"" >> $TEMPLATE_NAME + echo " echo \"e.g. to source a config file:\"" >> $TEMPLATE_NAME + echo " #. \"\$CONFIG_FILE\"" >> $TEMPLATE_NAME + echo "}" >> $TEMPLATE_NAME + echo >> $TEMPLATE_NAME echo "step_1_info() { echo \"My custom step\"; }" >> $TEMPLATE_NAME echo "step_1_alias() { ALIAS=\"begin\"; }" >> $TEMPLATE_NAME echo "step_1() {" >> $TEMPLATE_NAME @@ -669,6 +699,11 @@ main() { echo " [I] Staring sequence $(realpath $0) ..." + existsFunction step_config + if [ $? -eq 0 ] ; then + echo " [I] Running...step_config" + step_config + fi # check if more than one step is given and select execution mode if [ "${#START[@]}" -gt "1" ]; then selection "${START[@]}"